Rediģēt

Kopīgot, izmantojot


How to send events from Event Grid basic to Event Grid namespace topics

This article describes how to forward events from event subscriptions created in resources like topics, system topics, domains, and partner topics to Event Grid namespaces.

Overview

Event Grid basic supports Event Grid Namespace topic as the endpoint type. When creating an event subscription to an Event Grid topic, system topic, domain, or partner topic, you can select an Event Grid namespace topic as the endpoint for handling events.

Image that shows events forwarded from Event Grid basic to Event Grid namespace topic.

Namespace topic as a destination in Event Grid basic event subscriptions helps you with transitioning to Event Grid namespaces without modifying your existing workflow. Event Grid namespaces provide new and interesting capabilities that you might be interested to use in your solutions. If you're currently using Event Grid basic resources like topics, system topics, domains, and partner topics you only need to create a new event subscription in your current topic and select Event Grid namespace topic as a handler destination.

This article covers an example scenario where you forward Azure Storage events to an Event Grid namespace. Here are the high-level steps:

  1. Create a system topic for the Azure storage account and enable managed identity for the system topic.
  2. Assign the system topic's managed identity to the Event Grid Data Sender role on the destination Event Grid namespace.
  3. Create an event subscription to the system topic with the Event Grid namespace as the event handler, and use the managed identity for event delivery.

Prerequisites

  1. Create an Event Grid namespace resource by following instructions from Create, view, and manage namespaces.
  2. Create an Event Grid namespace topic by following instructions from Create, view, and manage namespace topics.
  3. Create an Event Grid event subscription in a namespace topic by following instructions from Create, view, and manage event subscriptions in namespace topics. This step is optional, but it's useful for testing the scenario.
  4. Create an Azure storage account by following instructions from create a storage account.

Create a system topic and enable managed identity for the storage account

If you have an existing system topic for the storage account, navigate to the system topic page. If you don't have one, create a system topic. Then, enable managed identity for the storage account.

  1. Navigate to Azure portal.

  2. In the search bar, search for Event Grid System Topics, and select it from the search results.

  3. On the Event Grid System Topics page, select + Create.

    Screenshot that shows the System Topics page with the Create button selected.

  4. On the Create Event Grid System Topic page, follow these steps:

    1. For Topic Types, select Storage Accounts.

    2. For Subscription, select the Azure subscription where you want to create the system topic.

    3. For Resource Group, select the resource group for the system topic.

    4. For Resource, select the Azure storage resource for which you want to create the system topic.

    5. In the System Topic Details section, for Name, enter a name for the topic.

    6. Select Review + create at the bottom of the page.

      Screenshot that shows the Create Event Grid System Topic page.

  5. On the Review + create page, review settings, and select Create.

    Screenshot that shows the Create Event Grid System Topic - Review and create page.

  6. After the deployment is successful, select Go to resource to navigate to the Event Grid System Topic page for the system topic you created.

Enable managed identity for the system topic

Now, enable managed identity for the system topic you created. For this example, let's create a system-assigned managed identity for the system topic.

  1. On the Event Grid System Topic page, select Identity under Settings on the left navigation menu.

  2. On the Identity page, select On for Status.

  3. Select Save on the command bar.

    Screenshot that shows the Identity page for the system topic.

  4. On the confirmation pop-up window, select Yes to confirm the creation of the managed identity.

  5. After the managed identity is created, you see the object (principal) ID for the identity.

    Keep the System Topic page open in the current tab of your web browser.

Grant the identity permission to send events to the namespace

In the last step, you created a system-assigned managed identity for your storage account's system topic. In this step, you grant the identity the permission to send events to the target or destination namespace.

  1. Launch a new tab or a window of the web browser. Navigate to your Event Grid namespace in the Azure portal.

  2. Select Access control (IAM) on the left menu.

  3. Select Add and then select Add role assignment.

    Screenshot that shows the Access control page for the Event Grid namespace.

  4. On the Role page, search for and select Event Grid Data Sender role, and then select Next.

    Screenshot that shows the Access control page with Event Grid Data Sender role selected.

  5. On the Members page, for Assign access to, select Managed identity, and then choose + Select members.

    Screenshot that shows the Members page.

  6. On the Select managed identities page, follow these steps:

    1. For Subscription, select the Azure subscription where the managed identity is created.

    2. For Managed identity, select Event Grid System Topic.

    3. For Select, type the name of your system topic.

    4. In the search results, select the managed identity. The managed identity's name is same as the system topic's name.

      Screenshot that shows the selection of a managed identity.

  7. On the Members page, select Next.

  8. On the Review + assign page, review settings, and select Review + assign at the bottom of the page.

Create an event subscription to the storage system topic

Now, you're ready to create an event subscription to the system topic for the source storage account using the namespace as an endpoint.

  1. On the System Topic page for the system topic, select Overview on the left menu if it's not already selected.

  2. Select + Event Subscription on the command bar.

    Screenshot that shows the Event Grid System Topic page with the Event Subscription button selected.

  3. On the Create Event Subscription page, follow these steps:

    1. For Name, enter the name for an event subscription.

    2. For Event Schema, select the event schema as Cloud Events Schema v1.0. It's the only schema type that the Event Grid Namespace Topic destination supports.

    3. For Filter to Event Types, select types of events you want to subscribe to.

    4. For Endpoint type, select Event Grid Namespace Topic.

    5. Select Configure an endpoint.

      Screenshot that shows the Create Event Subscription page with Configure an endpoint selected.

  4. On the Select Event Grid Namespace Topic page, follow these steps:

    1. For Subscription, select the Azure subscription, resource group, and the namespace that has the namespace topic.
    2. For Event Grid namespace topic, select the namespace topic.
    3. Select Confirm selection at the bottom of the page.
  5. Now, on the Create Event Subscription page, for Managed identity type, select System assigned.

  6. Select Create at the bottom of the page.

    Screenshot that shows how to create a subscription to forward events from Event Grid basic to Event Grid namespace topic.

    To test the scenario, create a container in the Azure blob storage and upload a file to it. Verify that the event handler or endpoint for your namespace topic receives the blob created event.

    When you upload a blob to a container in the Azure storage, here's what happens:

    1. Azure Blob Storage sends a Blob Created event to your blob storage's system topic.
    2. The event is forwarded to your namespace topic as it's the event handler or endpoint for the system topic.
    3. The endpoint for the subscription to the namespace topic receives the forwarded event.

See the following articles: