Descriptions
we want to build an ’app’ which can listen to a specific ‘storage account’, whenever a new file has been uploaded(we take this an event), this app will be triggered to do sth based on the event.
About Event Grid
Components
Events - What happened, alerts,facts
Event sources - Where the event took place.
Event generator/publisher - e.g. Storage blob
Topics - One of an endpoint where publishers send events.
Event subscriptions - The endpoint or built-in mechanism to route events, sometimes to more than one handler. Subscriptions are also used by handlers to intelligently filter incoming events.
Event handlers - The app or service reacting to the event.(Microsoft built-in service)
Event Grid Subscription - like an agent, connect the event generators and the end points.
Event Grid Domain- An event domain is a management tool for large numbers of Event Grid topics related to the same application
Event Grid Topics
Architecture
About Azure Storage Blob
Azure Blob storage is Microsoft’s object storage solution for the cloud.
ResourceGroup–> Storage Account–> Containers –> Blobs
Solution 1: build Azure function
Method 1: using Azure portal(recommended)
How to create storage blob trigger
Azure function bingding event grid
-
Create an Azure Function app using the Azure portal
-
Expand your function app and click the + button next to Functions. If this is the first function in your function app, select In-portal then Continue. Otherwise, go to step three.
-
choose more Template–> Event Grid trigger
-
select Add Event Grid subscription.
-
Create Event Subscription you will see more details about configuring the Event Subscription
Method 2: using Azure cli
prerequisites:
- Install Azure Core Tools version 2.x.
- Install the Azure CLI 2.0 +. az login
-
create a azure function project:
$func init myApp Select a worker runtime: 1. dotnet 2. node 3. python (preview) 4. powershell (preview) Choose option: 1 dotnet Writing /lhome/yxiaoli/Documents/myApp/.vscode/extensions.json
Better to chose dotnet…instead of python
-
generate app function:
$ cd myApp $ func new --name EventTrigger Select a template: 1. QueueTrigger 2. HttpTrigger 3. BlobTrigger 4. TimerTrigger 5. DurableFunctionsOrchestration 6. SendGrid 7. EventHubTrigger 8. ServiceBusQueueTrigger 9. ServiceBusTopicTrigger 10. EventGridTrigger 11. CosmosDBTrigger 12. IotHubTrigger Choose option: 10 Function name: EventTrigger The function "EventTrigger" was created successfully from the "EventGridTrigger" template.
-
customize your function
-
upload the Function App to Azure:
$func azure functionapp publish ${your-function-name}
Reference
-
using ‘azure.storage.blob’ return BlobBlockList –> BlobBlock(id, )
-
[what is event hub](https://hackernoon.com/azure-functions-choosing-between-queues-and-event-hubs-dac4157eee1c