Skip to content

Commit edaf179

Browse files
authored
Merge pull request #176547 from dominicbetts/central-msi
Add managed identities to data export
2 parents 1cc993f + 0c5b693 commit edaf179

12 files changed

+386
-49
lines changed

articles/iot-central/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@
200200
href: core/howto-control-devices-with-rest-api.md
201201
- name: Manage jobs
202202
href: core/howto-manage-jobs-with-rest-api.md
203+
- name: Manage applications
204+
href: core/howto-manage-iot-central-with-rest-api.md
203205
- name: Manage your devices
204206
items:
205207
- name: Manage devices individually

articles/iot-central/core/concepts-architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ In an IoT Central application you can manage the following security aspects of y
5353

5454
- [Device connectivity](concepts-get-connected.md): Create, revoke, and update the security keys that your devices use to establish a connection to your application.
5555
- [App integrations](howto-authorize-rest-api.md#get-an-api-token): Create, revoke, and update the security keys that other applications use to establish secure connections with your application.
56+
- [Data export](howto-export-data.md#connection-options): Use managed identities to secure the connection to your data export destinations.
5657
- [User management](howto-manage-users-roles.md): Manage the users that can sign in to the application and the roles that determine what permissions those users have.
5758
- [Organizations](howto-create-organizations.md): Define a hierarchy to manage which users can see which devices in your IoT Central application.
5859

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

Lines changed: 147 additions & 46 deletions
Large diffs are not rendered by default.

articles/iot-central/core/howto-manage-iot-central-from-cli.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Manage IoT Central from Azure CLI or PowerShell | Microsoft Docs
3-
description: This article describes how to create and manage your IoT Central application using the Azure CLI or PowerShell. You can view, modify, and remove the application using these tools.
3+
description: This article describes how to create and manage your IoT Central application using the Azure CLI or PowerShell. You can view, modify, and remove the application using these tools. You can also configure a managed system identity that can you can use to setup secure data export.
44
services: iot-central
55
ms.service: iot-central
66
author: dominicbetts
@@ -174,6 +174,30 @@ Remove-AzIotCentralApp -ResourceGroupName "MyIoTCentralResourceGroup" `
174174

175175
---
176176

177+
## Configure a managed identity
178+
179+
An IoT Central application can use a system assigned [managed identity](../../active-directory/managed-identities-azure-resources/overview.md) to secure the connection to a [data export destination](howto-export-data.md#connection-options).
180+
181+
To enable the managed identity, use either the [Azure portal - Configure a managed identity](howto-manage-iot-central-from-portal.md#configure-a-managed-identity) or the [REST API](howto-manage-iot-central-with-rest-api.md):
182+
183+
:::image type="content" source="media/howto-manage-iot-central-from-cli/managed-identity.png" alt-text="Screenshot showing managed identity in Azure portal.":::
184+
185+
After you enable the managed identity, you can use the CLI to configure the role assignments.
186+
187+
Use the [az role assignment create](/cli/azure/role/assignment#az_role_assignment_create) command to create a role assignment. For example, the following commands first retrieve the principal ID of the managed identity. The second command assigns the `Azure Event Hubs Data Sender` role to the principal ID in the scope of the `MyIoTCentralResourceGroup` resource group:
188+
189+
```azurecli-interactive
190+
spID=$(az resource list -n myiotcentralapp --query [*].identity.principalId --out tsv)
191+
az role assignment create --assignee $spID --role "Azure Event Hubs Data Sender" \
192+
--scope /subscriptions/<your subscription id>/resourceGroups/MyIoTCentralResourceGroup
193+
```
194+
195+
To learn more about the role assignments, see:
196+
197+
- [Built-in roles for Azure Event Hubs](../../event-hubs/authenticate-application.md#built-in-roles-for-azure-event-hubs)
198+
- [Built-in roles for Azure Service Bus](../../service-bus-messaging/authenticate-application.md#azure-built-in-roles-for-azure-service-bus)
199+
- [Built-in roles for Azure Storage Services](/rest/api/storageservices/authorize-with-azure-active-directory#manage-access-rights-with-rbac)
200+
177201
## Next steps
178202

179203
Now that you've learned how to manage Azure IoT Central applications from Azure CLI or PowerShell, here is the suggested next step:

articles/iot-central/core/howto-manage-iot-central-from-portal.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Manage and monitor IoT Central in the Azure portal | Microsoft Docs
3-
description: This article describes how to create, manage, and monitor your IoT Central applications from the Azure portal.
3+
description: This article describes how to create, manage, and monitor your IoT Central applications and enable managed identities from the Azure portal.
44
services: iot-central
55
ms.service: iot-central
66
author: dominicbetts
@@ -67,6 +67,25 @@ To move the application to a different subscription, select **change** beside t
6767

6868
![Management portal: resource management](media/howto-manage-iot-central-from-portal/highlight-subscription.png)
6969

70+
## Configure a managed identity
71+
72+
When you configure a data export in your IoT Central application, you can choose to configure the connection to the destination with a *connection string* or a [managed identity](../../active-directory/managed-identities-azure-resources/overview.md). Using a managed identity is more secure because you don't need to store the credentials for the destination in your IoT Central application. IoT Central currently uses [system-assigned managed identities](../../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types). To create the managed identity for your application, you use either the Azure portal or the REST API.
73+
74+
> [!NOTE]
75+
> You can only add a managed identity to an IoT Central application that was created in a region. All new applications are created in a region. To learn more, see [Updates](https://azure.microsoft.com/updates/azure-iot-central-new-and-updated-features-august-2021/).
76+
77+
When you configure a managed identity, the configuration includes a *scope* and a *role*:
78+
79+
* The scope defines where you can use the managed identity. For example, you can use an Azure resource group as the scope. In this case, both the IoT Central application and the destination must be in the same resource group.
80+
* The role defines what permissions the IoT Central application is granted in the destination service. For example, for an IoT Central application to send data to an event hub, the managed identity needs the **Azure Event Hubs Data Sender** role assignment.
81+
82+
[!INCLUDE [iot-central-managed-identity](../../../includes/iot-central-managed-identity.md)]
83+
84+
You can configure role assignments in the Azure portal or use the Azure CLI:
85+
86+
* To learn more about to configure role assignments in the Azure portal for specific destinations, see [Export IoT data to cloud destinations using data export](howto-export-data.md).
87+
* To learn more about how to configure role assignments using the Azure CLI, see [Manage IoT Central from Azure CLI or PowerShell](howto-manage-iot-central-from-cli.md).
88+
7089
## Monitor application health
7190

7291
> [!NOTE]
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Use the REST API to manage and monitor IoT Central applications | Microsoft Docs
3+
description: This article describes how to create and manage your IoT Central applications with the REST API. The REST API also lets you add a system assigned managed identity to your application.
4+
services: iot-central
5+
ms.service: iot-central
6+
author: dominicbetts
7+
ms.author: dobett
8+
ms.date: 10/25/2021
9+
ms.topic: how-to
10+
---
11+
12+
# Use the REST API to create and manage IoT Central applications
13+
14+
You can use the [control plane REST API](/rest/api/iotcentral/2021-06-01controlplane/apps) to create and manage IoT Central applications. You can also use the REST API to add a managed identity to your application.
15+
16+
To use this API, you need a bearer token for the `management.azure.com` resource. To get a bearer token, you can use the Azure CLI:
17+
18+
```azurecli
19+
az account get-access-token --resource https://management.azure.com
20+
```
21+
22+
## List your applications
23+
24+
To get a list of the IoT Central applications in a subscription:
25+
26+
```http
27+
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/iotApps?api-version=2021-06-01
28+
```
29+
30+
To get a list of the IoT Central applications in a resource group:
31+
32+
```http
33+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps?api-version=2021-06-01
34+
```
35+
36+
You can retrieve the details of an individual application:
37+
38+
```http
39+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{applicationName}?api-version=2021-06-01
40+
```
41+
42+
## Create an IoT Central application
43+
44+
To create an IoT Central application with a system assigned [managed identity](../../active-directory/managed-identities-azure-resources/overview.md):
45+
46+
```http
47+
PUT https://management.azure.com/subscriptions/<your subscription id>/resourceGroups/<your resource group name>/providers/Microsoft.IoTCentral/iotApps/<your application name>?api-version=2021-06-01
48+
```
49+
50+
The following payload shows the configuration for the new application, including the managed identity:
51+
52+
```json
53+
{
54+
"location": "eastus",
55+
"sku": {
56+
"name": "ST2"
57+
},
58+
"properties": {
59+
"displayName": "Contoso IoT Central App",
60+
"subdomain": "my-iot-central-app",
61+
"template": "[email protected]"
62+
},
63+
"identity": {
64+
"type": "SystemAssigned"
65+
}
66+
}
67+
```
68+
69+
## Modify an IoT Central application
70+
71+
You can modify an existing IoT Central application. The following example shows how to change the display name and enable the system assigned managed identity:
72+
73+
```http
74+
PATCH https://management.azure.com/subscriptions/<your subscription id>/resourceGroups/<your resource group name>/providers/Microsoft.IoTCentral/iotApps/<your application name>?api-version=2021-06-01
75+
```
76+
77+
Use the following payload to change the display name and enable the system assigned managed identity:
78+
79+
```json
80+
{
81+
"properties": {
82+
"displayName": "Contoso IoT Central App"
83+
},
84+
"identity": {
85+
"type": "SystemAssigned"
86+
}
87+
}
88+
```
89+
90+
> [!NOTE]
91+
> You can only add a managed identity to an IoT Central application that was created in a region. All new applications are created in a region. To learn more, see [Updates](https://azure.microsoft.com/updates/azure-iot-central-new-and-updated-features-august-2021/).
92+
93+
## Delete an IoT Central application
94+
95+
To delete an IoT Central application, use:
96+
97+
```http
98+
DELETE https://management.azure.com/subscriptions/<your subscription id>/resourceGroups/<your resource group name>/providers/Microsoft.IoTCentral/iotApps/<your application name>?api-version=2021-06-01
99+
```
100+
101+
## Next steps
102+
103+
Now that you've learned how to create and manage Azure IoT Central applications using the REST API, here is the suggested next step:
104+
105+
> [!div class="nextstepaction"]
106+
> [How to use the IoT Central REST API to manage users and roles](howto-manage-users-roles-with-rest-api.md)
56.2 KB
Loading

articles/iot-central/core/overview-iot-central-admin.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ To learn more, see [X.509 group enrollment](concepts-get-connected.md#x509-group
4646

4747
The administrator can also create and manage the API tokens that a client application uses to authenticate with your IoT Central application. Client applications use the REST API to interact with IoT Central.
4848

49+
For data exports, the administrator can configure [managed identities](../../active-directory/managed-identities-azure-resources/overview.md) to secure the connections to the [export destinations](howto-export-data.md). To learn more, see:
50+
51+
- [Configure a managed identity (Azure portal)](howto-manage-iot-central-from-portal.md#configure-a-managed-identity)
52+
- [Configure a managed identity (REST API)](howto-manage-iot-central-with-rest-api.md)
53+
- [Configure a managed identity (Azure CLI)](howto-manage-iot-central-from-cli.md#configure-a-managed-identity)
54+
4955
## Configure an application
5056

5157
The administrator can configure the behavior and appearance of an IoT Central application. To learn more, see:

articles/iot-central/core/overview-iot-central.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The IoT Central documentation refers to four user roles that interact with an Io
3131

3232
- A _solution builder_ is responsible for [creating an application](quick-deploy-iot-central.md), [configuring rules and actions](quick-configure-rules.md), [defining integrations with other services](quick-export-data.md), and further customizing the application for operators and device developers.
3333
- An _operator_ [manages the devices](howto-manage-devices-individually.md) connected to the application.
34-
- An _administrator_ is responsible for administrative tasks such as managing [user roles and permissions](howto-administer.md) within the application.
34+
- An _administrator_ is responsible for administrative tasks such as managing [user roles and permissions](howto-administer.md) within the application and [configuring managed identities](howto-manage-iot-central-from-portal.md#configure-a-managed-identity) for securing connects to other services.
3535
- A _device developer_ [creates the code that runs on a device](concepts-telemetry-properties-commands.md) or [IoT Edge module](concepts-iot-edge.md) connected to your application.
3636

3737
## Create your IoT Central application

includes/iot-central-create-export.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: iot-central
5+
author: dominicbetts
6+
ms.service: iot-central
7+
ms.topic: include
8+
ms.date: 10/20/2021
9+
ms.author: dobett
10+
ms.custom: include file
11+
---
12+
13+
Now that you have a destination to export your data to, set up data export in your IoT Central application:
14+
15+
1. Sign in to your IoT Central application.
16+
17+
1. In the left pane, select **Data export**.
18+
19+
> [!Tip]
20+
> If you don't see **Data export** in the left pane, then you don't have permissions to configure data export in your app. Talk to an administrator to set up data export.
21+
22+
1. Select **+ New export**.
23+
24+
1. Enter a display name for your new export, and make sure the data export is **Enabled**.
25+
26+
1. Choose the type of data to export. The following table lists the supported data export types:
27+
28+
| Data type | Description | Data format |
29+
| :------------- | :---------- | :----------- |
30+
| Telemetry | Export telemetry messages from devices in near-real time. Each exported message contains the full contents of the original device message, normalized. | [Telemetry message format](#telemetry-format) |
31+
| Property changes | Export changes to device and cloud properties in near-real time. For read-only device properties, changes to the reported values are exported. For read-write properties, both reported and desired values are exported. | [Property change message format](#property-changes-format) |
32+
| Device connectivity | Export device connected and disconnected events. | [Device connectivity message format](#device-connectivity-changes-format) |
33+
| Device lifecycle | Export device registered, deleted, provisioned, enabled, disabled, displayNameChanged, and deviceTemplateChanged events. | [Device lifecycle changes message format](#device-lifecycle-changes-format) |
34+
| Device template lifecycle | Export published device template changes including created, updated, and deleted. | [Device template lifecycle changes message format](#device-template-lifecycle-changes-format) |
35+
36+
1. Optionally, add filters to reduce the amount of data exported. There are different types of filter available for each data export type:
37+
<a name="DataExportFilters"></a>
38+
39+
| Type of data | Available filters|
40+
|--------------|------------------|
41+
|Telemetry|<ul><li>Filter by device name, device ID, device template, and if the device is simulated</li><li>Filter stream to only contain telemetry that meets the filter conditions</li><li>Filter stream to only contain telemetry from devices with properties matching the filter conditions</li><li>Filter stream to only contain telemetry that has *message properties* meeting the filter condition. *Message properties* (also known as *application properties*) are sent in a bag of key-value pairs on each telemetry message optionally sent by devices that use the device SDKs. To create a message property filter, enter the message property key you're looking for, and specify a condition. Only telemetry messages with properties that match the specified filter condition are exported. [Learn more about application properties from IoT Hub docs](../articles/iot-hub/iot-hub-devguide-messages-construct.md) </li></ul>|
42+
|Property changes|<ul><li>Filter by device name, device ID, device template, and if the device is simulated</li><li>Filter stream to only contain property changes that meet the filter conditions</li></ul>|
43+
|Device connectivity|<ul><li>Filter by device name, device ID, device template, organizations, and if the device is simulated</li><li>Filter stream to only contain changes from devices with properties matching the filter conditions</li></ul>|
44+
|Device lifecycle|<ul><li>Filter by device name, device ID, device template, and if the device is provisioned, enabled, or simulated</li><li>Filter stream to only contain changes from devices with properties matching the filter conditions</li></ul>|
45+
|Device template lifecycle|<ul><li>Filter by device template</li></ul>|
46+
47+
1. Optionally, enrich exported messages with extra key-value pair metadata. The following enrichments are available for the telemetry, property changes, device connectivity, and device lifecycle data export types:
48+
<a name="DataExportEnrichmnents"></a>
49+
- **Custom string**: Adds a custom static string to each message. Enter any key, and enter any string value.
50+
- **Property**, which adds to each message:
51+
- Device metadata such as device name, device template name, enabled, organizations, provisioned, and simulated.
52+
- The current device reported property or cloud property value to each message. If the exported message is from a device that doesn't have the specified property, the exported message doesn't get the enrichment.

0 commit comments

Comments
 (0)