Applications of AZURE EVENT GRID
- 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.
- 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.
- 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:
- Utilizing built-in events in Azure via Logic Apps to promptly react to changes in the blob.
- 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.
- Search for Subscription and select it.
- Go to Resource Providers.
- Search for “eventgrid” and check if it is already registered.
- If it is not yet registered, click on the “Register” button to register the Event Grid Resource Provider.
- 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.
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.
Step 16: Now we go back to our blob, and click on Refresh.
How To Set Up Azure Event Grid?
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.