|
| 1 | +--- |
| 2 | +title: Cross-tenant delivery in Azure Event Grid |
| 3 | +description: Describes how to publish and deliver events across tenants using an Azure Event Grid topic with a user-assigned identity. |
| 4 | +ms.topic: how-to |
| 5 | +ms.custom: devx-track-azurecli |
| 6 | +ms.date: 11/18/2024 |
| 7 | +# Customer intent: As a developer, I want to know how to delivery events using managed identity to a destination in another tenant. |
| 8 | +--- |
| 9 | + |
| 10 | +# Cross-tenant event delivery using a managed identity |
| 11 | +This article provides information on delivery of events where Azure Event Grid basic resources like topics, domains, system topics, and partner topics are in one tenant and the Azure destination resource is in another tenant. |
| 12 | + |
| 13 | +The following sections show you how to implement a sample scenario where an Azure Event Grid topic with a user-assigned identity as a federated credential delivers events to an Azure Storage Queue destination hosted in another tenant. Here are the high-level steps: |
| 14 | + |
| 15 | +1. Create an Azure Event Grid topic with a user-assigned managed identity in Tenant A. |
| 16 | +1. Create a multitenant app with a federated client credential. |
| 17 | +1. Create an Azure Storage Queue destination in Tenant B. |
| 18 | +1. While creating an event subscription to the topic, enable cross-tenant delivery and configure an endpoint. |
| 19 | + |
| 20 | +> [!NOTE] |
| 21 | +> - This feature is currently in preview. |
| 22 | +> - Cross-tenant delivery is currently available for the following endpoints: Service Bus topics and queues, Event Hubs, and Storage queues. |
| 23 | +
|
| 24 | +## Create a topic with a user-assigned identity (Tenant A) |
| 25 | +Create a user-assigned identity by following instructions in the [Manage user-assigned managed identities](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities) article. Then, enable a user-assigned managed identity while creating a topic or updating an existing topic by using steps in the following procedure. |
| 26 | + |
| 27 | +### Enable user-assigned identity for a new topic |
| 28 | +1. On the **Security** page of the topic or domain creation wizard, select **Add user assigned identity**. |
| 29 | +1. In the **Select user assigned identity** window, select the subscription that has the user-assigned identity, select the **user-assigned identity**, and then choose **Select**. |
| 30 | + |
| 31 | + :::image type="content" source="./media/managed-service-identity/create-page-add-user-assigned-identity-link.png" alt-text="Screenshot showing the Enable user-assigned identity option selected." lightbox="./media/managed-service-identity/create-page-add-user-assigned-identity-link.png"::: |
| 32 | + |
| 33 | + |
| 34 | +### Enable user-assigned identity for an existing topic |
| 35 | +1. On the **Identity** page, switch to the **User assigned** tab in the right pane, and then select **+ Add** on the toolbar. |
| 36 | + |
| 37 | + :::image type="content" source="./media/managed-service-identity/user-assigned-identity-add-button.png" alt-text="Screenshot showing the User Assigned Identity tab."::: |
| 38 | +1. In the **Add user managed identity** window, follow these steps: |
| 39 | + 1. Select the **Azure subscription** that has the user-assigned identity. |
| 40 | + 1. Select the **user-assigned identity**. |
| 41 | + 1. Select **Add**. |
| 42 | +1. Refresh the list in the **User assigned** tab to see the added user-assigned identity. |
| 43 | + |
| 44 | + |
| 45 | +For more information, see the following articles: |
| 46 | +- [Enable user-assigned identity for a system topic](enable-identity-system-topics.md) |
| 47 | +- [Enable user-assigned identity for a custom topic or a domain](enable-identity-custom-topics-domains.md) |
| 48 | + |
| 49 | +## Create a multitenant Application |
| 50 | + |
| 51 | +1. Create a Microsoft Entra app and update the registration to be multitenant. For details, see [Enable multitenant registration](/entra/identity-platform/howto-convert-app-to-be-multi-tenant#update-registration-to-be-multitenant). |
| 52 | + |
| 53 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/multi-tenant-app.png" alt-text="Screenshot that shows the Microsoft Entra app authentication setting set to Multitenant." lightbox="./media/cross-tenant-delivery-using-managed-identity/multi-tenant-app.png"::: |
| 54 | +1. Create the federated identity credential relationship between multitenant app and the user-assigned identity of the Event Grid topic using Graph API. |
| 55 | + |
| 56 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/federated-identity-credential-post-api.png" alt-text="Screenshot that shows the sample POST method to enable federated identity credential relationship between multitenant app and user-assigned identity." lightbox="./media/cross-tenant-delivery-using-managed-identity/federated-identity-credential-post-api.png"::: |
| 57 | + |
| 58 | + - In the URL, use the multitenant app object ID. |
| 59 | + - For **Name**, provide a unique name for the federated client credential. |
| 60 | + - For **Issuer**, use `https://login.microsoftonline.com/TENANTAID/v2.0` where `TENANTAID` is the ID of the tenant where the user-assigned identity is located. |
| 61 | + - For **Subject**, specify the client ID of the user-assigned identity. |
| 62 | + |
| 63 | + Verify and wait for the API call to succeed. |
| 64 | +1. Once the API call succeeds, proceed to verify that the federated client credential is set up correctly on the multitenant app. |
| 65 | + |
| 66 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/certificates-secrets-federated-credential.png" alt-text="Screenshot that shows the certificates and secrets page of the multitenant app." lightbox="./media/cross-tenant-delivery-using-managed-identity/certificates-secrets-federated-credential.png"::: |
| 67 | + |
| 68 | + > [!NOTE] |
| 69 | + > The subject identifier is the client ID of the user-assigned identity on the topic. |
| 70 | +
|
| 71 | +## Create destination storage account (Tenant B) |
| 72 | +Create a storage account in a tenant that's different from the tenant that has the source Event Grid topic and user-assigned identity. You create an event subscription to the topic (in tenant A) using the storage account (in tenant B) later. |
| 73 | + |
| 74 | +1. Create a storage account by following instructions from the [Create a storage account](../storage/common/storage-account-create.md#create-a-storage-account) article. |
| 75 | +1. Using the **Access Control (IAM)** page, add the multitenant app to the appropriate role so that the app can send events to the storage account. For example: Storage Account Contributor, Storage Queue Data Contributor, Storage Queue Data Message Sender. For instructions, see [Assign an Azure role for an Azure queue](../storage/queues/assign-azure-role-data-access.md#assign-an-azure-role). |
| 76 | + |
| 77 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/storage-role.png" alt-text="Screenshot that shows the Access Control (IAM) page for the storage account." lightbox="./media/cross-tenant-delivery-using-managed-identity/storage-role.png"::: |
| 78 | + |
| 79 | + |
| 80 | +## Enable cross-tenant delivery and configure the endpoint |
| 81 | +Create an event subscription on the topic with federated client credential information passed to deliver to the destination storage account. |
| 82 | + |
| 83 | +1. While creating an event subscription, enable **cross-tenant delivery** and select **Configure an endpoint**. |
| 84 | + |
| 85 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/create-subscription-cross-tenant.png" alt-text="Screenshot that shows the Create Event Subscription page with Cross-tenant delivery option enabled." lightbox="./media/cross-tenant-delivery-using-managed-identity/create-subscription-cross-tenant.png"::: |
| 86 | +1. On the **Endpoint** page, specify the subscription ID, resource group, storage account name, and the queue name in Tenant B. |
| 87 | + |
| 88 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/endpoint.png" alt-text="Screenshot that shows the Endpoint page." lightbox="./media/cross-tenant-delivery-using-managed-identity/endpoint.png"::: |
| 89 | +1. Now, in the **Managed Identity for Delivery** section, do these steps: |
| 90 | + 1. For **Managed identity type**, select **User Assigned**. |
| 91 | + 1. Select the **user-assigned identity** from the drop-down list. |
| 92 | + 1. For **Federated identity credentials**, enter the multitenant application ID. |
| 93 | + |
| 94 | + :::image type="content" source="./media/cross-tenant-delivery-using-managed-identity/managed-identity-for-delivery.png" alt-text="Screenshot that shows the Create Event Subscription page with the managed identity specified." lightbox="./media/cross-tenant-delivery-using-managed-identity/managed-identity-for-delivery.png"::: |
| 95 | +1. Select **Create** at the bottom of the page to create the event subscription. |
| 96 | + |
| 97 | + Now, publish event to topic and verify event is delivered successfully to destination storage account. |
0 commit comments