Open In App

How To Set Up Azure Event Grid?

Last Updated : 11 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Event Grid is like a notification service that lets different computer programs (like apps or services) talk to each other and send messages when something happens. It can be used when you want to automatically trigger a reaction in one program based on something happening in another program.

Azure Event Grid 

Event Grid is a highly scalable, serverless mediator that you can use to connect different applications through events. To subscriber destinations like applications, Azure services, or any other endpoint to which Event Grid has network access, events are provided by Event Grid. Other applications, SaaS services, and Azure services may be the origin of those occurrences.

Key Words

  • Events – What happened?
  • Event sources – Where the event took place.
  • Topics – The endpoint where publishers send events.
  • Event subscriptions – It refers to the destination or pre-existing system used to direct events to one or more event handlers. Handlers can use subscriptions to selectively receive only relevant events.
  • Event handlers – The app or service reacting to the event.
Azure Event Grid

 

Event Sources

  • User’s own service or solution: Event Grid allows you to publish your own events, and your customers can subscribe to them. There are two options available: Custom Topics or Domains, depending on your needs. Use Custom Topics if you want to control the event handling process, and use Domains if you want to deliver events to multiple teams.
  • Saas provider or platform: A company that provides software as a service can send their events to Event Grid using a feature called Partner Events. You can then subscribe to those events and automate tasks. Currently, events from partners like Auth0 and  Microsoft Graph API are available.
  • An Azure Service: Some of the Azure services that can send events to Event Grid are:
    • Azure Blob Storage
    • Azure Event Hubs
    • Azure IoT Hub
    • Azure Service Bus
    • Azure subscriptions

Event Handlers

These Azure services can currently handle events from Event Grid:

  • Webhooks
  • Azure functions 
  • Event Hubs 
  • Service Bus queues and topics 
  • Relay hybrid connections 
  • Storage queues

Features of AZURE EVENT GRID

  • Simplicity – Easily direct events from your Azure resource to any endpoint you choose with a simple click.
    Advanced filtering – Use filters to make sure the right endpoint receives only the relevant events based on event type or publish path.
  • Fan-out – Send multiple copies of the same event to different endpoints for redundancy or other purposes.
  • Reliability – Events are retried for up to 24 hours with gradually increasing time intervals to make sure they are delivered.
  • Pay-per-event – You only pay for the number of events you use Event Grid for, so you don’t have to worry about fixed costs.
  • High throughput – Event Grid can handle large volumes of events, so it’s suitable for high-demand applications.
  • Built-in Events – You can use built-in events that are predefined by Azure resources to get started quickly.
  • Custom Events – Use Event Grid to deliver custom events reliably and efficiently to the right endpoints based on your app’s specific needs.

Applications of AZURE EVENT GRID

  1. Serverless Application Architecture: Azure Event Grid is useful for serverless applications where you want to connect different parts of your application together. For example, you can use Event Grid to trigger an analysis function to start when a new video is uploaded to your blob storage.
  2. Ops Automation: Event Grid helps you automate tasks and make sure policies are followed. For example, you can use it to let Azure Automation know when a new virtual machine or database is created in Azure SQL. You can then use this information to check that the service is set up correctly, add information to your tools, label virtual machines, or create work items automatically.
  3. Application Integration: Event Grid helps your app communicate with other services. For instance, you can create a topic to send your app’s event data to Event Grid, which will ensure that the data is reliably delivered and routed to the correct place. You can also use Event Grid along with Logic Apps to process data without having to write any code.

There are two distinct methods for setting up Azure Event Grid:

  1. Utilizing built-in events in Azure via Logic Apps to promptly react to changes in the blob.
  2. Generating a custom Event by employing Logic Apps to dispatch customized events to our event grid topic.

In this article, we will utilize built-in events. For this, we perform the following actions,

  • Create a storage account
  • Create a Logic app
  • Create a container in a storage account 
  • Create an Event Grid
  • Add files to the container

Step 1: Navigate to your Azure portal.

 

Step 2: Click on the Create resource option. You will be listed with different resources that can be deployed on Azure.

 

Step 3: Type in a storage account in the search bar. Click on the Create option.

 

Step 4: You will be prompted to fill in details about the virtual network we wish to create. 

 

Step 5: In the basics tab, fill in the required details

  • Subscription: The subscription in which you wish to create the virtual network.
  • Resource Group: Choose the resource group where you wish to create the storage account. If you haven’t created one before, click “Create New”. You will be prompted to provide a name for the Resource group. Enter the name and click OK.
  • Storage Account Name: Provide a name for the Storage account.

 

Step 6: Click Review and on the next screen click on Create option.

 

Step 7: Go to Create a Resource and type in the logic app in the search bar and then click on the Create option.

Step 8: You will be prompted to fill in details about the Logic App we wish to create.

  • Name: Provide the name for the Logic App
  • Resource group: Choose the resource group where you wish to create the Logic app

 

Step 9: Click on Review and Create and on the next window click on the Create option.

Step 10: Go to Resource Groups from the left menu. Here we can see all our resources.

 

Note: Before proceeding to the next step, ensure that the following prerequisite is completed. This process needs to be done only once.

  1. Search for Subscription and select it.
  2. Go to Resource Providers.
  3.  Search for “eventgrid” and check if it is already registered.
  4. If it is not yet registered, click on the “Register” button to register the Event Grid Resource Provider.
  5. Once registered, you can proceed to use Event Grid.

Step 11: Creating a storage container

  • Navigate to the storage account you created in the Azure portal.
  • In the left-hand menu, click on Containers and then click Add Container.

 

  • Provide a name for the container and click Create.

 

Step 12: From the left-hand menu, navigate to the resource groups and select the Logic App that you want to use.

  • Click on Create a workflow in Designer and then on Add.

 

  • Provide a name for the workflow, select the appropriate State type, and click Create.

 

Step 13: Now, click on the workflow you created.

  • In the left menu, click on Designer.
  • Under Add a trigger, search for Event Grid.

 

  • Choose Azure Event Grid under Azure.

 

  • Select When a resource event occurs as the trigger.

 

  • On the next screen, you can either sign in with your Microsoft Account or choose Connect with Service principal.

Step 14: Under When a resource event occurs,

  • Subscription: Choose the subscription you have.
  • Resource Type: Choose the desired resource type (here we’ve chosen Microsoft.Storage.StorageAccounts)
  • Resource Name: Choose the resource name from the ones you created
  • Event Type Item – 1: Means what type of event you are reacting to. (In this case, Microsoft.Storage.BlobCreated)
    Click on Save.
resource event

 

Step 15: Upload files to a container in your storage account by selecting the container and dragging/dropping or browsing for files. Then click on upload.

storage account

 

Step 16:  Now we go back to our blob, and click on Refresh.

Status successful

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads