Skip to content

Commit 4d5f46a

Browse files
Merge pull request #101292 from spelluru/egridarm
Event Grid - ARM quickstart
2 parents 8b1e881 + fb40b08 commit 4d5f46a

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: 'Send Blob storage events to web endpoint - template'
3+
description: Use Azure Event Grid and an Azure Resource Manager template to create Blob storage account, and subscribe its events. Send the events to a Webhook.'
4+
services: event-grid
5+
keywords:
6+
author: spelluru
7+
ms.author: spelluru
8+
ms.date: 01/15/2020
9+
ms.topic: quickstart
10+
ms.service: event-grid
11+
---
12+
# Route Blob storage events to web endpoint by using Azure Resource Manager template
13+
Azure Event Grid is an eventing service for the cloud. In this article, you use an **Azure Resource Manager template** to create a Blob storage account, subscribe to events for that blob storage, and trigger an event to view the result. Typically, you send events to an endpoint that processes the event data and takes actions. However, to simplify this article, you send the events to a web app that collects and displays the messages.
14+
15+
[Resource Manager template](../azure-resource-manager/templates/overview.md) is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it. If you want to learn more about developing Resource Manager templates, see [Resource Manager documentation](/azure/azure-resource-manager/).
16+
17+
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/) before you begin.
18+
19+
## Prerequisites
20+
### Create a message endpoint
21+
Before subscribing to the events for the Blob storage, let's create the endpoint for the event message. Typically, the endpoint takes actions based on the event data. To simplify this quickstart, you deploy a [pre-built web app](https://github.com/Azure-Samples/azure-event-grid-viewer) that displays the event messages. The deployed solution includes an App Service plan, an App Service web app, and source code from GitHub.
22+
23+
1. Select **Deploy to Azure** to deploy the solution to your subscription. In the Azure portal, provide values for the parameters.
24+
25+
[Deploy to Azure](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fazure-event-grid-viewer%2Fmaster%2Fazuredeploy.json)
26+
1. The deployment may take a few minutes to complete. After the deployment has succeeded, view your web app to make sure it's running. In a web browser, navigate to:
27+
`https://<your-site-name>.azurewebsites.net`
28+
29+
1. You see the site but no events have been posted to it yet.
30+
31+
![View new site](./media/blob-event-quickstart-portal/view-site.png)
32+
33+
34+
## Create a storage account with an Event Grid subscription
35+
The template used in this quickstart is from [Azure Quickstart templates](https://github.com/Azure/azure-quickstart-templates/tree/master/101-event-grid-subscription-and-storage).
36+
37+
[!code-json[<Azure Resource Manager template create Blob strage Event Grid subscription>](~/quickstart-templates/101-event-grid-subscription-and-storage/azuredeploy.json)]
38+
39+
Two Azure resources are defined in the template:
40+
41+
* **Microsoft.Storage/storageAccounts**: create an Azure Storage account.
42+
* **"Microsoft.Storage/storageAccounts/providers/eventSubscriptions**: create an Azure Event Grid subscription for the storage account.
43+
44+
1. Select the following link to sign in to Azure and open a template. The template creates a key vault and a secret.
45+
46+
[Deploy to Azure](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-event-grid-subscription-and-storage%2Fazuredeploy.json)
47+
2. Specify the **endpoint**: provide the URL of your web app and add `api/updates` to the home page URL.
48+
3. Select **Purchase** to deploy the template.
49+
50+
The Azure portal is used here to deploy the template. You can also use the Azure PowerShell, Azure CLI, and REST API. To learn other deployment methods, see [Deploy templates](../azure-resource-manager/templates/deploy-powershell.md).
51+
52+
> [!NOTE]
53+
> You can find more Azure Event Grid template samples [here](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Eventgrid).
54+
55+
## Validate the deployment
56+
View your web app again, and notice that a subscription validation event has been sent to it. Select the eye icon to expand the event data. Event Grid sends the validation event so the endpoint can verify that it wants to receive event data. The web app includes code to validate the subscription.
57+
58+
![View subscription event](./media/blob-event-quickstart-portal/view-subscription-event.png)
59+
60+
Now, let's trigger an event to see how Event Grid distributes the message to your endpoint.
61+
62+
You trigger an event for the Blob storage by uploading a file. The file doesn't need any specific content. The articles assumes you have a file named testfile.txt, but you can use any file.
63+
64+
When you upload the file to the Azure Blob storage, Event Grid sends a message to the endpoint you configured when subscribing. The message is in the JSON format and it contains an array with one or more events. In the following example, the JSON message contains an array with one event. View your web app and notice that a blob created event was received.
65+
66+
![View results](./media/blob-event-quickstart-portal/view-results.png)
67+
68+
69+
70+
## Clean up resources
71+
When no longer needed, [delete the resource group](../azure-resource-manager/management/delete-resource-group.md?tabs=azure-portal#delete-resource-group
72+
).
73+
74+
## Next steps
75+
For more information about Azure Resource Manager templates, see the following articles:
76+
77+
- [Azure Resource Manager documentation](/azure/azure-resource-manager)
78+
- [Define resources in Azure Resource Manager templates](/azure/templates/)
79+
- [Azure Quickstart templates](https://azure.microsoft.com/resources/templates/)
80+
- [Azure Event Grid templates](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Eventgrid).
3.08 KB
Loading

articles/event-grid/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
href: ../storage/blobs/storage-blob-event-quickstart-powershell.md?toc=%2fazure%2fevent-grid%2ftoc.json
2020
- name: Portal
2121
href: blob-event-quickstart-portal.md
22+
- name: Template
23+
displayName: arm, resource manager template
24+
href: blob-event-quickstart-template.md
2225
- name: Custom events
2326
items:
2427
- name: Azure CLI

0 commit comments

Comments
 (0)