Skip to content

Commit 8bbabcf

Browse files
authored
Merge pull request #186817 from dominicbetts/central-adx-mi
Add ADX managed identities
2 parents 5cf0f48 + 2f7aab3 commit 8bbabcf

File tree

2 files changed

+114
-18
lines changed

2 files changed

+114
-18
lines changed

articles/iot-central/core/howto-export-data.md

Lines changed: 114 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: How to use the new data export to export your IoT data to Azure and
44
services: iot-central
55
author: dominicbetts
66
ms.author: dobett
7-
ms.date: 10/20/2021
7+
ms.date: 01/31/2022
88
ms.topic: how-to
99
ms.service: iot-central
1010
ms.custom: contperf-fy21q1, contperf-fy21q3
@@ -84,6 +84,53 @@ IoT Central exports data in near real time to a database table in the Azure Data
8484

8585
To query the exported data in the Azure Data Explorer portal, navigate to the database and select **Query**.
8686

87+
### Connection options
88+
89+
Azure Data Explorer destinations let you configure the connection with a *service principal* or a [managed identity](../../active-directory/managed-identities-azure-resources/overview.md).
90+
91+
Managed identities are more secure because:
92+
93+
- You don't store the credentials for your resource in your IoT Central application.
94+
- The credentials are automatically tied to the lifetime of your IoT Central application.
95+
- Managed identities automatically rotate their security keys regularly.
96+
97+
IoT Central currently uses [system-assigned managed identities](../../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types).
98+
99+
When you configure a managed identity, the configuration includes a *scope* and a *role*:
100+
101+
- The scope defines where you can use the managed identity.
102+
- The role defines what permissions the IoT Central application is granted in the destination service.
103+
104+
This article shows how to create a managed identity using the Azure CLI. You can also use the Azure portal to create a manged identity.
105+
106+
# [Webhook](#tab/webhook)
107+
108+
For webhook destinations, IoT Central exports data in near real time. The data in the message body is in the same format as for Event Hubs and Service Bus.
109+
110+
### Create a webhook destination
111+
112+
You can export data to a publicly available HTTP webhook endpoint. You can create a test webhook endpoint using [RequestBin](https://requestbin.net/). RequestBin throttles request when the request limit is reached:
113+
114+
1. Open [RequestBin](https://requestbin.net/).
115+
1. Create a new RequestBin and copy the **Bin URL**. You use this URL when you test your data export.
116+
117+
To create the Azure Data Explorer destination in IoT Central on the **Create new destination** page:
118+
119+
1. Enter a **Destination name**.
120+
121+
1. Select **Webhook** as the destination type.
122+
123+
1. Paste the callback URL for your webhook endpoint. You can optionally configure webhook authorization and add custom headers.
124+
125+
- For **OAuth2.0**, only the client credentials flow is supported. When you save the destination, IoT Central communicates with your OAuth provider to retrieve an authorization token. This token is attached to the `Authorization` header for every message sent to this destination.
126+
- For **Authorization token**, you can specify a token value that's directly attached to the `Authorization` header for every message sent to this destination.
127+
128+
1. Select **Save**.
129+
130+
---
131+
132+
# [Service principal](#tab/service-principal/data-explorer)
133+
87134
### Create an Azure Data Explorer destination
88135

89136
If you don't have an existing Azure Data Explorer database to export to, follow these steps:
@@ -152,31 +199,80 @@ To create the Azure Data Explorer destination in IoT Central on the **Create new
152199
153200
:::image type="content" source="media/howto-export-data/export-destination.png" alt-text="Screenshot of Azure Data Explorer export destination.":::
154201
155-
# [Webhook](#tab/webhook)
202+
# [Managed identity](#tab/managed-identity/data-explorer)
156203
157-
For webhook destinations, IoT Central exports data in near real time. The data in the message body is in the same format as for Event Hubs and Service Bus.
204+
### Create an Azure Data Explorer destination
158205
159-
### Create a webhook destination
206+
If you don't have an existing Azure Data Explorer database to export to, follow these steps. You have two choices to create an Azure Data Explorer database:
160207
161-
You can export data to a publicly available HTTP webhook endpoint. You can create a test webhook endpoint using [RequestBin](https://requestbin.net/). RequestBin throttles request when the request limit is reached:
208+
- Create a new Azure Data Explorer cluster and database. To learn more, see the [Azure Data Explorer quickstart](/azure/data-explorer/create-cluster-database-portal). Make a note of the cluster URI and the name of the database you create, you need these values in the following steps.
209+
- Create a new Azure Synapse Data Explorer pool and database. To learn more, see the [Azure Data Explorer quickstart](../../synapse-analytics/get-started-analyze-data-explorer.md). Make a note of the pool URI and the name of the database you create, you need these values in the following steps.
162210
163-
1. Open [RequestBin](https://requestbin.net/).
164-
1. Create a new RequestBin and copy the **Bin URL**. You use this URL when you test your data export.
211+
To configure the managed identity that enables your IoT Central application to securely export data to your Azure resource:
212+
213+
1. Create a managed identity for your IoT Central application to use to connect to your database. Use the Azure Cloud Shell to run the following command:
214+
215+
```azurecli
216+
az iot central app identity assign --name {your IoT Central app name} \
217+
--resource-group {resource group name} \
218+
--system-assigned
219+
```
220+
221+
Make a note of the `principalId` and `tenantId` output by the command. You use these values in the following step.
222+
223+
1. Configure the database permissions to allow connections from your IoT Central application. Use the Azure Cloud Shell to run the following command:
224+
225+
```azurecli
226+
az kusto database-principal-assignment create --cluster-name {name of your cluster} \
227+
--database-name {name of your database} \
228+
--resource-group {resource group name} \
229+
--principal-assignment-name {name of your IoT Central application} \
230+
--principal-id {principal id from the previous step} \
231+
--principal-type App --role Admin \
232+
--tenant-id {tenant id from the previous step}
233+
```
234+
235+
> [!TIP]
236+
> If you're using Azure Synapse, see [`az synapse kusto database-principal-assignment`](/cli/azure/synapse/kusto/database-principal-assignment).
237+
238+
1. Create a table in your database with a suitable schema for the data you're exporting. The following example query creates a table called `smartvitalspatch`. To learn more, see [Transform data inside your IoT Central application for export](howto-transform-data-internally.md):
239+
240+
```kusto
241+
.create table smartvitalspatch (
242+
EnqueuedTime:datetime,
243+
Message:string,
244+
Application:string,
245+
Device:string,
246+
Simulated:boolean,
247+
Template:string,
248+
Module:string,
249+
Component:string,
250+
Capability:string,
251+
Value:dynamic
252+
)
253+
```
254+
255+
1. (Optional) To speed up ingesting data into your Azure Data Explorer database:
256+
257+
1. Navigate to the **Configurations** page for your Azure Data Explorer cluster. Then enable the **Streaming ingestion** option.
258+
1. Run the following query to alter the table policy to enable streaming ingestion:
259+
260+
```kusto
261+
.alter table smartvitalspatch policy streamingingestion enable
262+
```
165263
166264
To create the Azure Data Explorer destination in IoT Central on the **Create new destination** page:
167265
168266
1. Enter a **Destination name**.
169267
170-
1. Select **Webhook** as the destination type.
268+
1. Select **Azure Data Explorer** as the destination type.
171269
172-
1. Paste the callback URL for your webhook endpoint. You can optionally configure webhook authorization and add custom headers.
270+
1. Enter your Azure Data Explorer cluster or pool URL, database name, and table name. Select **System-assigned managed identity** as the authorization type.
173271
174-
- For **OAuth2.0**, only the client credentials flow is supported. When you save the destination, IoT Central communicates with your OAuth provider to retrieve an authorization token. This token is attached to the `Authorization` header for every message sent to this destination.
175-
- For **Authorization token**, you can specify a token value that's directly attached to the `Authorization` header for every message sent to this destination.
176-
177-
1. Select **Save**.
272+
> [!TIP]
273+
> The cluster URL for a standalone Azure Data Explorer looks like `https://<ClusterName>.<AzureRegion>.kusto.windows.net`. The cluster URL for an Azure Synapse Data Explorer pool looks like `https://<DataExplorerPoolName>.<SynapseWorkspaceName>.kusto.azuresynapse.net`.
178274
179-
---
275+
:::image type="content" source="media/howto-export-data/export-destination-managed.png" alt-text="Screenshot of Azure Data Explorer export destination.":::
180276
181277
# [Connection string](#tab/connection-string/event-hubs)
182278
@@ -196,9 +292,9 @@ If you don't have an existing Event Hubs namespace to export to, follow these st
196292
- Copy either the primary or secondary connection string. You use this connection string to set up a new destination in IoT Central.
197293
- Alternatively, you can generate a connection string for the entire Event Hubs namespace:
198294
1. Go to your Event Hubs namespace in the Azure portal.
199-
2. Under **Settings**, select **Shared Access Policies**
295+
2. Under **Settings**, select **Shared Access Policies**.
200296
3. Create a new key or choose an existing key that has **Send** permissions.
201-
4. Copy either the primary or secondary connection string
297+
4. Copy either the primary or secondary connection string.
202298
203299
To create the Event Hubs destination in IoT Central on the **Create new destination** page:
204300
@@ -271,9 +367,9 @@ If you don't have an existing Service Bus namespace to export to, follow these s
271367
- Copy either the primary or secondary connection string. You use this connection string to set up a new destination in IoT Central.
272368
- Alternatively, you can generate a connection string for the entire Service Bus namespace:
273369
1. Go to your Service Bus namespace in the Azure portal.
274-
2. Under **Settings**, select **Shared Access Policies**
370+
2. Under **Settings**, select **Shared Access Policies**.
275371
3. Create a new key or choose an existing key that has **Send** permissions.
276-
4. Copy either the primary or secondary connection string
372+
4. Copy either the primary or secondary connection string.
277373
278374
To create the Service Bus destination in IoT Central on the **Create new destination** page:
279375
49.5 KB
Loading

0 commit comments

Comments
 (0)