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
Use [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) to use Microsoft Entra to authenticate a connection to IoT Hub. `DefaultAzureCredential` supports different authentication mechanisms and determines the appropriate credential type based of the environment it's executing in. It attempts to use multiple credential types in an order until it finds a working credential. For more information on setting up Entra for IoT Hub, see [Control access to IoT Hub by using Microsoft Entra ID](/azure/iot-hub/authenticate-authorize-azure-ad).
15
+
##### Entra token credential
16
+
17
+
Use [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) to use Microsoft Entra to authenticate a connection to IoT Hub. `DefaultAzureCredential` supports different authentication mechanisms and determines the appropriate credential type based on the environment it's executing in. It attempts to use multiple credential types in an order until it finds a working credential. For more information on setting up Entra for IoT Hub, see [Control access to IoT Hub by using Microsoft Entra ID](/azure/iot-hub/authenticate-authorize-azure-ad).
16
18
17
19
To create required Microsoft Entra app parameters for `DefaultAzureCredential`, create a Microsoft Entra app registration that contains your preferred authentication mechanism:
18
20
@@ -22,8 +24,12 @@ To create required Microsoft Entra app parameters for `DefaultAzureCredential`,
22
24
23
25
For more information, see [Quickstart: Register an application with the Microsoft identity platform](/entra/identity-platform/quickstart-register-app).
24
26
27
+
#### Entra app permissions
28
+
25
29
Microsoft Entra apps may require permissions depending on operations performed. For example, [IoT Hub Twin Contributor](/azure/role-based-access-control/built-in-roles/internet-of-things#iot-hub-twin-contributor) is required to enable read and write access to a IoT Hub device and module twins. For more information, see [Azure built-in roles](/azure/role-based-access-control/built-in-roles#internet-of-things).
26
30
31
+
### Connect to IoT Hub
32
+
27
33
Add these packages and statements to your code to use the Microsoft Entra library.
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-connect-service-iothub-entra-node.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,21 @@ For an overview of Node.js SDK authentication, see:
16
16
*[Getting started with user authentication on Azure](/azure/developer/javascript/how-to/with-authentication/getting-started)
17
17
*[Azure Identity client library for JavaScript](/javascript/api/overview/azure/identity-readme)
18
18
19
-
### Entra token credential
19
+
#####Entra token credential
20
20
21
21
Use [DefaultAzureCredential](/javascript/api/@azure/identity/defaultazurecredential) to generate a token. The token will be supplied to `fromTokenCredential`.
22
22
23
-
### Connect to IoT Hub
23
+
To create required Microsoft Entra app parameters for `DefaultAzureCredential`, create a Microsoft Entra app registration that contains your selected authentication mechanism:
24
+
25
+
* Client secret
26
+
* Certificate
27
+
* Federated identity credential
28
+
29
+
For more information, see [Quickstart: Register an application with the Microsoft identity platform](/entra/identity-platform/quickstart-register-app).
30
+
31
+
Microsoft Entra apps may require permissions depending on operations performed. For example, [IoT Hub Twin Contributor](/azure/role-based-access-control/built-in-roles/internet-of-things#iot-hub-twin-contributor) is required to enable read and write access to a IoT Hub device and module twins. For more information, see [Azure built-in roles](/azure/role-based-access-control/built-in-roles#internet-of-things).
32
+
33
+
##### Connect to IoT Hub
24
34
25
35
Use [fromTokenCredential](/javascript/api/azure-iothub/registry?#azure-iothub-registry-fromtokencredential) to create a service connection to IoT Hub using an Entra token credential.
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-connect-service-iothub-entra-python.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,25 @@ ms.manager: lizross
11
11
ms.date: 11/06/2024
12
12
---
13
13
14
-
For an overview of Python SDK authentication, see [Authenticate Python apps to Azure services by using the Azure SDK for Python](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication/overview)
14
+
For an overview of Python SDK authentication, see [Authenticate Python apps to Azure services by using the Azure SDK for Python](/azure/developer/python/sdk/authentication/overview)
15
15
16
16
### Entra token credential
17
17
18
18
You must generate and supply a token credential to `from_token_credential`.
19
19
20
20
[DefaultAzureCredential](/azure/developer/python/sdk/authentication/overview#use-defaultazurecredential-in-an-application) is the easiest way to generate a token. You can also use credential chains to generate a token. For more information, see [Credential chains in the Azure Identity client library for Python](/azure/developer/python/sdk/authentication/credential-chains).
21
21
22
-
### Connect to IoT Hub
22
+
To create required Microsoft Entra app parameters for `DefaultAzureCredential`, create a Microsoft Entra app registration that contains your selected authentication mechanism:
23
+
24
+
* Client secret
25
+
* Certificate
26
+
* Federated identity credential
27
+
28
+
For more information, see [Quickstart: Register an application with the Microsoft identity platform](/entra/identity-platform/quickstart-register-app).
29
+
30
+
Microsoft Entra apps may require permissions depending on operations performed. For example, [IoT Hub Twin Contributor](/azure/role-based-access-control/built-in-roles/internet-of-things#iot-hub-twin-contributor) is required to enable read and write access to a IoT Hub device and module twins. For more information, see [Azure built-in roles](/azure/role-based-access-control/built-in-roles#internet-of-things).
31
+
32
+
#### Connect to IoT Hub
23
33
24
34
Use [from_token_credential](/python/api/azure-iot-hub/azure.iot.hub.iothubregistrymanager?#azure-iot-hub-iothubregistrymanager-from-token-credential) to create a service connection to IoT Hub using an Entra token credential.
25
35
@@ -28,7 +38,7 @@ Use [from_token_credential](/python/api/azure-iot-hub/azure.iot.hub.iothubregist
28
38
* The Azure service URL
29
39
* The Azure credential token
30
40
31
-
In this example, the Azure credential is obtained using `DefaultAzureCredential`. THe Azure domain URL and credential are then supplied to `BlobServiceClient`.
41
+
In this example, the Azure credential is obtained using `DefaultAzureCredential`. The Azure domain URL and credential are then supplied to `BlobServiceClient`.
You can connect a backend service to IoT Hub using the following methods:
168
+
169
+
* Shared access policy
170
+
* Microsoft Entra
171
+
172
+
#### Connect using a shared access policy
173
+
167
174
Connect to IoT hub using [from_connection_string](/python/api/azure-iot-hub/azure.iot.hub.iothubregistrymanager?#azure-iot-hub-iothubregistrymanager-from-connection-string).
168
175
169
176
The SDK methods in this section require these shared access policy permissions:
### Retrieve and update module identity twin desired properties
185
196
186
197
You can update desired properties from a backend application using [update_module_twin](/python/api/azure-iot-hub/azure.iot.hub.iothubregistrymanager?#azure-iot-hub-iothubregistrymanager-update-module-twin).
0 commit comments