Get Notified Via Azure Event Grid Whenever Azure Blob Is Updated

In this article, we will learn how to get notifications whenever something is changed in Azure Blob Storage. Let’s say, we want our application to get notified whenever any new file is uploaded to the blob or say any file is deleted from the blob. How can we do that?
 
Before directly jumping into the solution, let’s have all the major pieces listed here which will contribute towards this.
 
Azure Storage
 
We need an Azure storage wherein we will be uploading our blog objects, i.e. image files.
 
Azure Event Grid
 
Next we need is Azure Event Grid. It is a routing service provided by Microsoft and the best part about this service is, it has built-in support for events coming from storage blobs and resource groups. So, we need to create a subscription that will tell what event and which specific topic we are interested in.
 
Endpoint
 
Lastly, we need an endpoint, which will receive notifications. So, it could be Function App, Logic App, or any custom application which is hosted somewhere and is accessible over HTTP.
 
With this much brief theoretical knowledge, we are good to proceed with implementation.
 
As a first step, one needs to login to Azure portal and create an endpoint. So, for creating an endpoint, we will use Function App with trigger type as Azure Event Grid Trigger.
 
The below image shows the required fields for creating a function app. To know more about how to create a Function App, a nice tutorial is given here.
 
 
Once Function App is created, you will notice that a URL is generated as shown below,
 
 
Next, we need to create an Azure storage account with a blob container. Detailed steps to create such content are provided over here. Once the storage account is ready, one can click on Events as shown below and can create a subscription,
 
 
Once you click on + Event Subscription, you will get a new view wherein you need to populate certain details as shown below screenshot,
 
 
In this example, we just want to monitor when a file is uploaded to Azure storage and that’s the reason, we selected Event Type as Blob Created. Click on Create and you will notice that our new subscription is listed under Event Subscriptions.
 
Now it’s time to upload an image file to a storage container. Once the file is uploaded to the container, we may have to wait up to 5 minutes to get notified and after certain minutes, you will notice that you have received notifications in Function App for all the images which were uploaded, as shown in the below screenshot,
 
If you want to have a look at a complete demo of this article, you can view at my channel.
 
 
Hope you enjoyed learning this notification mechanism. Happy learning!