Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Quickstart: Use Azure Event Grid to route Blob storage events to web endpoint (Azure portal)

Feedback

In this article

Event Grid is a fully managed service that enables you to easily manage events across many different Azure services and applications. It simplifies building event-driven and serverless applications. For an overview of the service, seeEvent Grid overview.

If you don't have an Azure account, create afree account before you begin.

When you're finished, you see that the event data is sent to the web app.

Screenshot that shows the sample Azure Event Grid Viewer app with an event.

Create a storage account

  1. Sign in toAzure portal.

  2. To create a Blob storage, selectCreate a resource.

  3. In theSearch, enterStorage account, and selectStorage account from the result list.

    Screenshot showing the search for Storage account on the Create a resource page.

  4. On theStorage account page, selectCreate to start creating the storage account. To subscribe to events, create either a general-purpose v2 storage account or a Blob storage account.

  5. On theCreate storage account page, do the following steps:

    1. Select your Azure subscription.

    2. ForResource group, create a new resource group or select an existing one.

    3. Enter thename for your storage account.

    4. Select theRegion in which you want the storage account to be created.

    5. ForPrimary service, selectAzure Blob Storage or Azure Data Lake Storage Gen 2.

    6. ForRedundancy, selectLocally-redundant storage (LRS) from the drop-down list.

    7. SelectReview + create at the bottom of the page.

      Screenshot showing the Create a storage account page.

    8. On theReview + create tab, review the settings, and selectCreate.

      Note

      Only storage accounts of kindStorageV2 (general purpose v2) andBlobStorage support event integration.Storage (general purpose v1) doesnot support integration with Event Grid.

  6. The deployment takes a few minutes to complete. On theDeployment page, selectGo to resource.

    Screenshot showing the deployment succeeded page with a link to go to the resource.

  7. On theStorage account page, selectEvents on the left menu.

    Screenshot showing the Events page for an Azure storage account.

  8. Keep this page in the web browser open.

Create a message endpoint

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 aprebuilt web app that displays the event messages. The deployed solution includes an App Service plan, an App Service web app, and source code from GitHub.

  1. SelectDeploy to Azure to deploy the solution to your subscription.

    Button to deploy the Resource Manager template to Azure.

  2. On theCustom deployment page, do the following steps:

    1. ForResource group, select the resource group that you created when creating the storage account. It will be easier for you to clean up after you're done with the tutorial by deleting the resource group.

    2. ForSite Name, enter a name for the web app.

    3. ForHosting plan name, enter a name for the App Service plan to use for hosting the web app.

    4. SelectReview + create.

      Screenshot showing the Custom deployment page.

  3. On theReview + create page, selectCreate.

  4. The deployment takes a few minutes to complete. On theDeployment page, selectGo to resource group.

    Screenshot showing the deployment succeeded page with a link to go to the resource group.

  5. On theResource group page, in the list of resources, select the web app that you created. You also see the App Service plan and the storage account in this list.

    Screenshot that shows the selection of web app in the resource group.

  6. On theApp Service page for your web app, select the URL to navigate to the web site. The URL should be in this format:https://<your-site-name>.azurewebsites.net.

    Screenshot that shows the selection of link to navigate to web app.

  7. Confirm that you see the site but no events are posted to it yet.

    View new site.

    Important

    Keep the Azure Event Grid Viewer window open so that you can see events as they are posted.

Subscribe to the Blob storage

You subscribe to a topic to tell Event Grid which events you want to track, and where to send the events.

  1. If you closed theStorage account page, navigate to your Azure Storage account that you created earlier. On the left menu, selectAll resources and select your storage account.

  2. On theStorage account page, selectEvents on the left menu.

  3. SelectMore Options, andWeb Hook. You're sending events to your viewer app using a web hook for the endpoint.

    Screenshot showing the selection of Web Hook on the Events page.

  4. On theCreate Event Subscription page, do the following steps:

    1. Enter aname for the event subscription.

    2. Enter aname for thesystem topic. To learn about system topics, seeOverview of system topics.

    3. Confirm thatEndpoint type is set toWeb Hook.

      Screenshot showing the Create Event Subscription page with a name for the system topic.

  5. ForEndpoint, selectConfigure an endpoint, and enter the URL of your web app and addapi/updates to the home page URL (for example:https://spegridsite.azurewebsites.net/api/updates), and then selectConfirm Selection.

    Screenshot showing the Select Web Hook page.

  6. Now, on theCreate Event Subscription page, selectCreate to create the event subscription.

    Screenshot showing the Create Event Subscription page with all fields selected.

  7. View your web app again, and notice that a subscription validation event is 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.

    Screenshot showing the Event Grid Viewer with the subscription validation event.

Now, let's trigger an event to see how Event Grid distributes the message to your endpoint.

Send an event to your endpoint

You trigger an event for the Blob storage by uploading a file. The file doesn't need any specific content.

  1. In the Azure portal, navigate to your Blob storage account, and selectContainers on the let menu.

  2. Select+ Container. Give your container a name, and use any access level, and selectCreate.

    Screenshot showing the New container page.

  3. Select your new container.

    Screenshot showing the selection of the container.

  4. To upload a file, selectUpload. On theUpload blob page, browse and select a file that you want to upload for testing, and then selectUpload on that page.

    Screenshot showing the Upload blob page to upload a sample image.

  5. Browse to your test file and upload it.

  6. You triggered the event, and Event Grid sent the 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 ablob created event was received.

    Screenshot showing the Event Grid Viewer page with the Blob Created event.

Clean up resources

If you plan to continue working with this event, don't clean up the resources created in this article. Otherwise, delete the resources you created in this article.

Select the resource group, and selectDelete resource group.

Related content

Now that you know how to create custom topics and event subscriptions, learn more about what Event Grid can help you do:


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?