Skip to content

Commit e9f8932

Browse files
committed
Edits and added Entra connection text
1 parent 9795e05 commit e9f8932

5 files changed

+92
-36
lines changed

articles/iot-hub/how-to-device-management.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,26 @@ manager: lizross
88
ms.service: azure-iot-hub
99
ms.devlang: csharp
1010
ms.topic: how-to
11-
ms.date: 10/09/2024
11+
ms.date: 11/25/2024
1212
zone_pivot_groups: iot-hub-howto-c2d-1
1313
---
1414

1515
# Get started with device management
1616

1717
Back-end apps can use Azure IoT Hub primitives, such as [device twins](iot-hub-devguide-device-twins.md) and [direct methods](iot-hub-devguide-direct-methods.md), to remotely start and monitor device management actions on devices.
1818

19-
Use a direct method to initiate device management actions (such as reboot, factory reset, and firmware update) from a back-end app in the cloud.
19+
Use a direct method to initiate device management actions (such as reboot, factory reset, and firmware update) from a back-end application.
2020

2121
The device is responsible for:
2222

2323
* Handling the method request sent from IoT Hub.
24-
2524
* Initiating the corresponding device-specific action on the device.
26-
2725
* Providing status updates through reported properties to IoT Hub.
2826

29-
The back-end app can run device twin queries to report on the progress of the device management actions.
30-
31-
This article shows you how a back-end app and a device app can work together to initiate and monitor a remote device action using direct methods and device twins. For this article, we use a device reboot as an example:
27+
This article shows you how a back-end app and a device app can work together to initiate and monitor a remote device action using a direct method.
3228

33-
* A service app calls a direct method to reboot in a device app through an IoT hub. The service app then displays the response and updated reported properties.
34-
* A device app handles a direct method to reboot a device and updates the last reboot time.
29+
* A service app calls a direct method to reboot in a device app through an IoT hub.
30+
* A device app handles a direct method to reboot a device.
3531

3632
[!INCLUDE [iot-hub-basic](../../includes/iot-hub-basic-whole.md)]
3733

includes/iot-hub-howto-device-management-dotnet.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.author: kgremban
77
ms.service: iot-hub
88
ms.devlang: csharp
99
ms.topic: include
10-
ms.date: 10/09/2024
10+
ms.date: 11/25/2024
1111
ms.custom: mqtt, devx-track-csharp, devx-track-dotnet
1212
---
1313

@@ -27,6 +27,13 @@ This section describes how to use device application code to create a direct met
2727

2828
Device client applications written in C# require the **Microsoft.Azure.Devices.Client** NuGet package.
2929

30+
Add these `using` statements to use the device library.
31+
32+
```csharp
33+
using Microsoft.Azure.Devices.Client;
34+
using Microsoft.Azure.Devices.Shared;
35+
```
36+
3037
### Connect to a device
3138

3239
The [DeviceClient](/dotnet/api/microsoft.azure.devices.client.deviceclient) class exposes all the methods required to interact with device messages from the device.
@@ -125,8 +132,24 @@ The [ServiceClient](/dotnet/api/microsoft.azure.devices.serviceclient) class exp
125132

126133
Backend service applications require the **Microsoft.Azure.Devices** NuGet package.
127134

135+
Add these `using` statements to use the service library.
136+
137+
```csharp
138+
using Microsoft.Azure.Devices;
139+
using Microsoft.Azure.Devices.Shared;
140+
```
141+
128142
### Connect to IoT hub
129143

144+
You can connect a backend service to IoT Hub using the following methods:
145+
146+
* Shared access policy
147+
* Microsoft Entra
148+
149+
[!INCLUDE [iot-authentication-service-connection-string.md](iot-authentication-service-connection-string.md)]
150+
151+
#### Connect using a shared access policy
152+
130153
Connect a backend application using [CreateFromConnectionString](/dotnet/api/microsoft.azure.devices.serviceclient.createfromconnectionstring?#microsoft-azure-devices-serviceclient-createfromconnectionstring(system-string-microsoft-azure-devices-serviceclientoptions)).
131154

132155
To invoke a direct method on a device through IoT Hub, your service needs the **service connect** permission. By default, every IoT Hub is created with a shared access policy named **service** that grants this permission.
@@ -141,6 +164,10 @@ static string connectionString = "{IoT hub service shared access policy connecti
141164
client = ServiceClient.CreateFromConnectionString(connectionString);
142165
```
143166

167+
#### Connect using Microsoft Entra
168+
169+
[!INCLUDE [iot-hub-howto-connect-service-iothub-entra-dotnet](iot-hub-howto-connect-service-iothub-entra-dotnet.md)]
170+
144171
### Invoke a method on a device
145172

146173
To invoke a method on a device:

includes/iot-hub-howto-device-management-java.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.author: kgremban
77
ms.service: iot-hub
88
ms.devlang: csharp
99
ms.topic: include
10-
ms.date: 10/09/2024
10+
ms.date: 11/25/2024
1111
ms.custom: amqp, mqtt, devx-track-java, devx-track-extended-java
1212
---
1313

@@ -23,7 +23,7 @@ This section describes how to use device application code to create a direct met
2323

2424
[!INCLUDE [iot-authentication-device-connection-string.md](iot-authentication-device-connection-string.md)]
2525

26-
### Device import statements
26+
### Device import statement
2727

2828
Use the following device import statement to access the Azure IoT SDK for Java.
2929

@@ -88,6 +88,15 @@ The `ServiceClient` [DeviceMethod](/java/api/com.microsoft.azure.sdk.iot.service
8888

8989
### Connect to IoT hub
9090

91+
You can connect a backend service to IoT Hub using the following methods:
92+
93+
* Shared access policy
94+
* Microsoft Entra
95+
96+
[!INCLUDE [iot-authentication-service-connection-string.md](iot-authentication-service-connection-string.md)]
97+
98+
#### Connect using a shared access policy
99+
91100
Use the [DeviceMethod](/java/api/com.microsoft.azure.sdk.iot.service.devicetwin.devicemethod?#com-microsoft-azure-sdk-iot-service-devicetwin-devicemethod-devicemethod(java-lang-string)) constructor to add the service primary connection string and connect to IoT Hub.
92101

93102
To invoke a direct method on a device through IoT Hub, your service needs the **service connect** permission. By default, every IoT Hub is created with a shared access policy named **service** that grants this permission.
@@ -101,6 +110,10 @@ public static final String iotHubConnectionString = "HostName=xxxxx.azure-device
101110
DeviceMethod methodClient = new DeviceMethod(iotHubConnectionString);
102111
```
103112

113+
#### Connect using Microsoft Entra
114+
115+
[!INCLUDE [iot-hub-howto-connect-service-iothub-entra-java](iot-hub-howto-connect-service-iothub-entra-java.md)]
116+
104117
### Invoke a method on a device
105118

106119
Call [invoke](/java/api/com.microsoft.azure.sdk.iot.service.devicetwin.devicemethod?#method-details) to invoke a method on a device and return its result.

includes/iot-hub-howto-device-management-node.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.author: kgremban
77
ms.service: iot-hub
88
ms.devlang: csharp
99
ms.topic: include
10-
ms.date: 10/09/2024
10+
ms.date: 11/25/2024
1111
ms.custom: mqtt, devx-track-js
1212
---
1313

@@ -19,11 +19,7 @@ This article describes how to use the [Azure IoT SDK for Node.js](https://github
1919

2020
## Create a device application
2121

22-
This section describes how to use device application code to:
23-
24-
* Respond to a direct method called by the cloud
25-
* Trigger a simulated device reboot
26-
* Use the reported properties to enable device twin queries to identify devices and when they were last rebooted
22+
This section describes how to use device application code to create a direct method callback.
2723

2824
### Install SDK packages
2925

@@ -161,7 +157,7 @@ The Azure IoT SDK for Node.js provides working samples of device apps that handl
161157

162158
## Create a backend application
163159

164-
This section describes how to initiate a remote reboot on a device using a direct method. The app uses device twin queries to discover the last reboot time for that device.
160+
This section describes how to invoke a direct method on a device.
165161

166162
### Install service SDK package
167163

@@ -177,6 +173,15 @@ The [Registry](/javascript/api/azure-iothub/registry) class exposes all methods
177173

178174
### Connect to IoT hub
179175

176+
You can connect a backend service to IoT Hub using the following methods:
177+
178+
* Shared access policy
179+
* Microsoft Entra
180+
181+
[!INCLUDE [iot-authentication-service-connection-string.md](iot-authentication-service-connection-string.md)]
182+
183+
#### Connect using a shared access policy
184+
180185
Use [fromConnectionString](/javascript/api/azure-iothub/registry?#azure-iothub-registry-fromconnectionstring) to connect to IoT hub.
181186

182187
To invoke a direct method on a device through IoT Hub, your service needs the **service connect** permission. By default, every IoT Hub is created with a shared access policy named **service** that grants this permission.
@@ -191,6 +196,10 @@ var client = Client.fromConnectionString(connectionString);
191196
var registry = Registry.fromConnectionString(serviceConnectionString);
192197
```
193198

199+
#### Connect using Microsoft Entra
200+
201+
[!INCLUDE [iot-hub-howto-connect-service-iothub-entra-node](iot-hub-howto-connect-service-iothub-entra-node.md)]
202+
194203
### Invoke a method on a device
195204

196205
Use [invokeDeviceMethod](/javascript/api/azure-iothub/client?#azure-iothub-client-invokedevicemethod) to invoke a direct method by name on a device. The method name parameter identifies the direct method. The method name is "reboot" in the examples within this article.

includes/iot-hub-howto-device-management-python.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,29 @@ ms.author: kgremban
77
ms.service: iot-hub
88
ms.devlang: csharp
99
ms.topic: include
10-
ms.date: 10/09/2024
10+
ms.date: 11/25/2024
1111
ms.custom: mqtt, devx-track-python, py-fresh-zinc
1212
---
1313

1414
* **Python SDK** - [Python version 3.7 or later](https://www.python.org/downloads/) is recommended. Make sure to use the 32-bit or 64-bit installation as required by your setup. When prompted during the installation, make sure to add Python to your platform-specific environment variable.
1515

16-
* Device applications require the **azure-iot-device** package. You can install the package using this command:
16+
## Overview
1717

18-
```cmd/sh
19-
pip install azure-iot-device
20-
```
18+
This article describes how to use the [Azure IoT SDK for Python](https://github.com/Azure/azure-iot-sdk-python) to create device and backend service application code for device direct methods.
2119

22-
* Service applications require the **azure-iot-hub** package. You can install the package using this command:
20+
## Install packages
2321

24-
```cmd/sh
25-
pip install azure-iot-hub
26-
```
22+
The **azure-iot-device** library must be installed to create device applications.
2723

28-
## Overview
24+
```cmd/sh
25+
pip install azure-iot-device
26+
```
2927

30-
This article describes how to use the [Azure IoT SDK for Python](https://github.com/Azure/azure-iot-sdk-python) to create device and backend service application code for device direct methods.
28+
The **azure-iot-hub** library must be installed to create backend service applications.
29+
30+
```cmd/sh
31+
pip install azure-iot-hub
32+
```
3133

3234
## Create a device application
3335

@@ -41,12 +43,10 @@ This section describes how to use device application code to:
4143

4244
### Device import statements
4345

44-
Add import statements to access `IoTHubDeviceClient` and `MethodResponse`.
46+
Add this import to access `IoTHubDeviceClient` and `MethodResponse`.
4547

4648
```python
4749
# import the device client library
48-
import time
49-
import datetime
5050
from azure.iot.device import IoTHubDeviceClient, MethodResponse
5151
```
5252

@@ -59,7 +59,7 @@ Call [create_from_connection_string](/python/api/azure-iot-device/azure.iot.devi
5959
```python
6060
# substitute the device connection string in conn_str
6161
# and add it to the IoTHubDeviceClient object
62-
conn_str = "{IOT hub device connection string}"
62+
conn_str = "{IoT hub device connection string}"
6363
device_client = IoTHubDeviceClient.create_from_connection_string(conn_str)
6464
```
6565

@@ -127,14 +127,21 @@ The [IoTHubRegistryManager](/python/api/azure-iot-hub/azure.iot.hub.iothubregist
127127
Add these import statements to connect to Iot Hub, receive cloud-to-device methods, and call device twin methods.
128128

129129
```python
130-
import sys, time
131-
132130
from azure.iot.hub import IoTHubRegistryManager
133131
from azure.iot.hub.models import CloudToDeviceMethod, CloudToDeviceMethodResult, Twin
134132
```
135133

136134
### Connect to IoT hub
137135

136+
You can connect a backend service to IoT Hub using the following methods:
137+
138+
* Shared access policy
139+
* Microsoft Entra
140+
141+
[!INCLUDE [iot-authentication-service-connection-string.md](iot-authentication-service-connection-string.md)]
142+
143+
#### Connect using a shared access policy
144+
138145
Connect to IoT hub using [from_connection_string](/python/api/azure-iot-hub/azure.iot.hub.iothubregistrymanager?#azure-iot-hub-iothubregistrymanager-from-connection-string). As a parameter, supply the **IoT Hub service connection string** that you created in the prerequisites section.
139146

140147
To invoke a direct method on a device through IoT Hub, your service needs the **service connect** permission. By default, every IoT Hub is created with a shared access policy named **service** that grants this permission.
@@ -149,6 +156,10 @@ IOTHUB_CONNECTION_STRING = "{IoT hub service connection string}"
149156
iothub_registry_manager = IoTHubRegistryManager.from_connection_string(IOTHUB_CONNECTION_STRING)
150157
```
151158

159+
#### Connect using Microsoft Entra
160+
161+
[!INCLUDE [iot-hub-howto-connect-service-iothub-entra-python](iot-hub-howto-connect-service-iothub-entra-python.md)]
162+
152163
### Invoke a method on a device
153164

154165
You can invoke a direct method by name on a device. The method name identifies the method. The method name is "rebootTime" in the examples within this article.

0 commit comments

Comments
 (0)