In this article, we’ll follow up on the previous article, Event Subscription Using Web Hook and learn to trigger an event to endpoint for any upload done to the Azure Storage account we created earlier which can be viewed in the web app. This is the last article on the Azure Event Grid article series.
Azure Event Grid
Azure Event Grid makes it possible to send the event data from a particular source to handlers. Basically, the Azure Event Grid helps to connect application to numerous other services. As the name says, the Azure Event Grid is a feature enabled by Azure which makes it possible for event-based architecture while building applications. Through the Azure Event Grid, all the incoming events such as resource groups and blob storage are supported. Furthermore, with the custom topics developer’s own events too are supported by the Azure Event Grid. Simply select the Azure Resource to subscribe to and all then we require to do is connect Webhook endpoint or the event handler to the event. Filters can be accessed in order to route certain events to various endpoints, multicast to the multiple endpoints making sure all the events are properly delivered.
Pre-requisites
- Read the article, Azure Event Grid and follow up the process to enable the event grid resource provider.
- Follow the article, Azure Storage Account and create an Azure Storage Account.
- Create message endpoint following the Routing Blob Storage Events Using Azure Event Grid tutorial.
- Check through the Event Subscription Using Web Hook article and successfully subscribe to the storage event using WebHook.
Now, let us learn to send event to the endpoint in this article.
Step 1
Visit the resource group you’ve created in the Azure Portal following the above tutorials.
Step 2
Under the resource group, you’ll have storage account, event grid system topic, an app service plan and app service. Click on the storage account.
Step 3
You’ll be taken to the storage account profile.
On the left-hand side menu, click on the Containers.
Step 4
Now, click on + Container button.
Step 5
Next, name your container and select the public access level. You can select the Private access level.
Once done, click on Create.
Step 6
As the storage container is created, we are notified.
As we check the containers under the storage account, we can see the new container name listed here. Click on it.
Step 7
Now, select the Upload button.
On the right-hand side, click on Select a file and choose the file you want to upload from your system.
We can also see the details of the uploaded life such as the name and size.
Step 8
Now, visit the web app and here we can see the details of the event now. The Storage blob storage created event is shown as the image is uploaded. We can also get the details of the subscription validation event.
With this, we have successfully triggered event using the Azure Event Grid. For every new image or any file uploaded to the storage account, we’ll have the update on the web app page with detail.
Delete services and resources
Step 9
Now, as we have successfully completed all the tasks and finally come to the end of the Azure Event Grid article series, it is wise to delete the services and resources to save ourselves from any charges to incur later on.
For this, visit the Azure Portal page. Select the resource group name.
Here, we can see there are four services running – the storage account - “ojashstorage”, the Event Grid System Topic - “ojashwebsystopic”, the app service plan - “testwebappplan” and the app service - “testwebappojash”.
We can delete these individually too, but as we have organized and created all of them within one resource group, we can simply delete all of them at once by deleting the resource group itself.
For this, on the top menu, click on Delete Resource Group.
Next, as the dialog box pops up, retype the name of the resource group and click on the Delete Button.
Finally, we have deleted all the services and resources now.
Conclusion
Thus, in this article, we learned to trigger the event to endpoint. Following up on the previous article, we successfully trigger any file upload to the storage account to create an event to endpoint which can be seen in the web app page. With this, we have come to the end of the Azure Event Grid Article series. Hopefully, you’ve learned a few more skills in Azure which will come handy in future projects and tasks in your career.