You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3,50 +3,77 @@ title: Create a cross-tenant data connection for Azure Data Explorer
3
3
description: Learn how to create a cross-tenant data connection for an Azure Event Hubs or Azure Event Grid service in a different tenant
4
4
ms.reviewer: vilauzon
5
5
ms.topic: reference
6
-
ms.date: 11/13/2023
6
+
ms.date: 02/06/2025
7
7
---
8
8
# Cross-tenant data connection
9
9
10
-
When you need to create a data connection for an Azure Event Hubs or Azure Event Grid service in a different tenant, use our [API](/rest/api/azurerekusto/dataconnections/createorupdate) to build the connection.
10
+
When you need to create a data connection for an Azure Event Hubs or Azure Event Grid service in a different tenant, use the [Create Data Connections API](/rest/api/azurerekusto/dataconnections/createorupdate) to build the connection.
11
11
12
-
In the following example, you'll use PowerShell to create a cross-tenant Event Hubs data connection and [auxiliary tokens](/azure/azure-resource-manager/management/authenticate-multi-tenant) to authenticate.
12
+
In this article, you learn how to use PowerShell to create a cross-tenant Event Hubs data connection and [auxiliary tokens](/azure/azure-resource-manager/management/authenticate-multi-tenant) to authenticate.
13
13
14
14
## Prerequisites
15
15
16
16
* If you don't have an Azure subscription, create a [free Azure account](https://azure.microsoft.com/free/) before you begin.
17
-
* Create an [event hub with data for ingestion](ingest-data-event-hub-overview.md) with an account in *Tenant1*, [email protected].
18
-
* Create [a test cluster and database](create-cluster-and-database.md), with an account in *Tenant2*, [email protected].
17
+
* Create an Event Hub in *Tenant1*. This is the tenant that hosts the source Event Hubs.
18
+
* Create [a test cluster and database](create-cluster-and-database.md) in *Tenant2*. This is the tenant that hosts the destination cluster.
19
+
* A single Entra account with access to both tenants or a [multitenant service principal](/entra/identity-platform/howto-convert-app-to-be-multi-tenant).
19
20
20
-
## Assign role to Tenant2 in Event Hubs
21
+
## Permissions
21
22
22
-
1. In the Azure portal, browse to your Event Hubs namespace.
23
-
1. In the left menu, select **Access control (IAM)** > **Add role assignments**
23
+
The Entra account or multitenant service principal must have at least the following permissions:
24
+
25
+
- Data Explorer: Contributor
26
+
- Event Hubs Namespace: [Azure Event Hubs Data Owner](/azure/role-based-access-control/built-in-roles#azure-event-hubs-data-owner)
24
27
25
-
:::image type="content" source="media/cross-tenant-ingestion/access-control.png" alt-text="Screenshot of Event Hubs namespace.":::
28
+
> [!NOTE]
29
+
> The account can be local or guest to Tenant1 or Tenant2, as long as it has the prerequisite permissions.
30
+
> Permissions must be at the Namespace level, and not at the Event Hubs level.
26
31
27
-
1. In the **Add role assignment** window, fill out the following information, and then select **Save**.
32
+
## Assign role to the Entra Account or Service Principal in Event Hubs for Tenant1
33
+
34
+
1. In the Azure portal, browse to your Event Hubs namespace.
28
35
29
-
:::image type="content" source="media/cross-tenant-ingestion/add-role-assignment.png" alt-text="Screenshot of Add role assignment window in the Azure portal.":::
36
+
1. In the left menu, select **Access control (IAM)** > **Add role assignments**.
30
37
31
-
|**Setting**|**Suggested value**|
32
-
|---|---|
38
+
1. In the **Add role assignment** window, enter the settings in the table, and then select **Save**.
39
+
40
+
|**Setting**|**Suggested value**|
41
+
|--|--|
33
42
| Role |[Azure Event Hubs Data Owner](/azure/role-based-access-control/built-in-roles#azure-event-hubs-data-owner)|
34
43
| Assign access to | User, group, or service principal |
35
-
| Select | The email address of the user in *Tenant2*|
44
+
| Select | The email address of the Entra user or Service Principal ID |
45
+
46
+
## Assign role to the Entra Account or Service Principal in the cluster for Tenant2
47
+
48
+
1. In the Azure portal, browse to your Data Explorer cluster.
49
+
50
+
1. In the left menu, select **Access control (IAM)** > **Add role assignments**.
51
+
52
+
1. In the **Add role assignment** window, enter the settings in the table and then select **Save**.
53
+
54
+
|**Setting**|**Suggested value**|
55
+
|--|--|
56
+
| Role |[Contributor](/azure/role-based-access-control/built-in-roles/privileged#contributor)|
57
+
| Assign access to | User, group, or service principal |
58
+
| Select | The email address of the Entra user or Service Principal ID |
59
+
60
+
## Set up the cross-tenant data connection
61
+
62
+
Set up a cross-tenant data connection between the cluster and Event Hubs using PowerShell.
36
63
37
-
1. When you receive an email invite on the selected address (`[email protected] account`), accept the invitation.
64
+
**Before you begin**
38
65
39
-
## Get an access token for Tenant1
66
+
Create the `Get-AzCachedAccessToken` function to get the access token for *Tenant1*. The source code for the function can be found in the [PowerShell gallery](https://www.powershellgallery.com/packages/AzureSimpleREST/0.2.64/Content/internal%5Cfunctions%5CGet-AzCachedAccessToken.ps1). You can include this code in your personal PowerShell profile to make it easier to call, or you can run it and then use it in these steps.
40
67
41
-
Before you begin, you'll need the `Get-AzCachedAccessToken` function to get the access token for *Tenant1*. The source code for the function can be found in the [PowerShell gallery](https://www.powershellgallery.com/packages/AzureSimpleREST/0.2.64/Content/internal%5Cfunctions%5CGet-AzCachedAccessToken.ps1). You can include this code in your personal PowerShell profile to make it easier to call, or you can run it and then use it in these steps.
68
+
# [Entra account](#tab/entra)
42
69
43
-
1. Run the following command to connect to *Tenant1*:
70
+
1. Run the following command to connect to the Event Hubs subscription in *Tenant1*:
1. Add a URI variable to use when invoking the web request:
112
+
1. Add a URI variable to use as a cluster resource, when invoking the web request:
87
113
88
114
```PowerShell
89
-
$adxdcuri="https://management.azure.com/subscriptions/<subscription ID>/resourceGroups/<resource group name>/providers/Microsoft.Kusto/clusters/<adx cluster name>/databases/<adx db name>/dataconnections/<adx data connection name>?api-version=2020-02-15"
115
+
$adxdcuri="https://management.azure.com/subscriptions/<subscriptionID>/resourceGroups/<resource group name>/providers/Microsoft.Kusto/clusters/<ADXClusterName>/databases/<ADXdbName>/dataconnections/<ADXDataConnectionName>?api-version=2020-02-15"
You should now be able to see the newly created data connection in the Azure portal.
124
+
# [Service Principal account](#tab/spa)
100
125
101
-
> [!NOTE]
102
-
> If the access used to build the data connection is revoked on Event Hubs, make sure you delete the data connection. Otherwise, Azure Data Explorer will continue to ingest data even if access on Event Hubs is revoked.
1. Verify that you can now see the newly created data connection in the Azure portal.
203
+
204
+
1. *Optional*: After establishing the data connection, you can revoke or delete the previously granted permissions for the Entra Account or Service Principal. Since the cluster ingestion uses the Event Hubs keys, these permissions are no longer required.
205
+
206
+
> [!IMPORTANT]
207
+
> If the primary or secondary Event Hubs keys are rotated, data ingestion might stop working. In that case, you need to drop and recreate the data connection.
103
208
104
209
## Related content
105
210
106
211
* [Query data in Azure Data Explorer](web-query-data.md)
212
+
* [Convert to multitenant](/entra/identity-platform/howto-convert-app-to-be-multi-tenant)
0 commit comments