Skip to content

Commit 0740ef5

Browse files
committed
Updates
1 parent 272b93b commit 0740ef5

File tree

3 files changed

+21
-35
lines changed

3 files changed

+21
-35
lines changed

articles/iot-hub/TOC.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,18 @@
305305
- name: New version
306306
displayName: device management, status updates, device maintenance windows
307307
href: how-to-device-management.md
308+
- name: .NET
309+
displayName: device management, status updates, device maintenance windows
310+
href: device-management-dotnet.md
311+
- name: Python
312+
displayName: device management, status updates, device maintenance windows
313+
href: device-management-python.md
314+
- name: Node.js
315+
displayName: device management, status updates, device maintenance windows
316+
href: device-management-node.md
317+
- name: Java
318+
displayName: device management, status updates, device maintenance windows
319+
href: device-management-java.md
308320
- name: Schedule and broadcast jobs
309321
items:
310322
- name: CLI

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ ms.devlang: csharp
1010
ms.topic: how-to
1111
ms.date: 10/09/2024
1212
zone_pivot_groups: iot-hub-howto-c2d-1
13-
ms.custom: mqtt, devx-track-csharp, devx-track-dotnet
1413
---
1514

1615
# Get started with device management
@@ -39,29 +38,9 @@ This article shows you how to develop two types of applications:
3938
4039
## Prerequisites
4140

42-
* **An IoT hub**. Some SDK calls require the IoT Hub primary connection string, so make a note of the connection string.
41+
* **An IoT hub**
4342

44-
* **A registered device**. Some SDK calls require the device primary connection string, so make a note of the connection string.
45-
46-
* **IoT Hub service connection string**
47-
48-
In this article, you create a back-end service that adds desired properties to a device twin and then queries the identity registry to find all devices with reported properties that have been updated accordingly. Your service needs the **service connect** permission to modify desired properties of a device twin, and it needs the **registry read** permission to query the identity registry. There is no default shared access policy that contains only these two permissions, so you need to create one.
49-
50-
To create a shared access policy that grants **service connect** and **registry read** permissions and get a connection string for this policy, follow these steps:
51-
52-
1. In the Azure portal, select **Resource groups**. Select the resource group where your hub is located, and then select your hub from the list of resources.
53-
54-
1. On the left-side pane of your hub, select **Shared access policies**.
55-
56-
1. From the top menu above the list of policies, select **Add shared policy access policy**.
57-
58-
1. In the **Add shared access policy** pane on the right, enter a descriptive name for your policy, such as "serviceAndRegistryRead". Under **Permissions**, select **Registry Read** and **Service Connect**, and then select **Add**.
59-
60-
1. Select your new policy from the list of policies.
61-
62-
1. Select the copy icon for the **Primary connection string** and save the value.
63-
64-
For more information about IoT Hub shared access policies and permissions, see [Control access to IoT Hub with shared access signatures](/azure/iot-hub/authenticate-authorize-sas).
43+
* **A registered device**
6544

6645
* If your application uses the MQTT protocol, make sure that **port 8883** is open in your firewall. The MQTT protocol communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see [Connecting to IoT Hub (MQTT)](../iot/iot-mqtt-connect-to-iot-hub.md#connecting-to-iot-hub).
6746

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ The `CreateFromConnectionString` [TransportType](/dotnet/api/microsoft.azure.dev
4343
* `Amqp`
4444
* `Amqp_WebSocket_Only`
4545
* `Amqp_Tcp_Only`
46-
47-
The `Http1` protocol is not supported for device twin updates.
46+
* `Http1`
4847

4948
This example connects to a device using the `Mqtt` transport protocol.
5049

@@ -61,9 +60,9 @@ deviceClient = DeviceClient.CreateFromConnectionString(DeviceConnectionString,
6160

6261
### Create a direct method callback
6362

64-
Use [SetMethodHandlerAsync](/dotnet/api/microsoft.azure.devices.client.deviceclient.setmethodhandlerasync) to initialize a callback listener method.
63+
Use [SetMethodHandlerAsync](/dotnet/api/microsoft.azure.devices.client.deviceclient.setmethodhandlerasync) to initialize a direct method callback listener. The listener is associated with a method name keyword, such as "reboot". The method name can be used in an IoT Hub or backend application to trigger the callback method on the device.
6564

66-
This example sets up a callback listener named `onReboot`.
65+
This example sets up a callback listener named `onReboot` that will trigger when the "reboot" direct method name is called.
6766

6867
```csharp
6968
try
@@ -86,7 +85,7 @@ catch (Exception ex)
8685
}
8786
```
8887

89-
In this example, the `onReboot` callback method implements the direct method on the device:
88+
In this example, the `onReboot` callback method implements the direct method on the device. This code updates reported properties related to a simulated device reboot. The reported properties can be read and verified by an IoT Hub or backend application, as demonstrated in the **Create a backend application** section of this article.
9089

9190
```csharp
9291
static Task<MethodResponse> onReboot(MethodRequest methodRequest, object userContext)
@@ -132,15 +131,11 @@ The Azure IoT SDK for .NET provides working samples of device apps that handle d
132131
* [Temperature Controller](https://github.com/Azure/azure-iot-sdk-csharp/tree/main/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController)
133132
* [Thermostat Sample](https://github.com/Azure/azure-iot-sdk-csharp/tree/main/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat)
134133

135-
## Get the IoT hub connection string
136-
137-
[!INCLUDE [iot-hub-howto-device-management-shared-access-policy-text](iot-hub-howto-device-management-shared-access-policy-text.md)]
138-
139134
## Create a backend application
140135

141136
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.
142137

143-
The [ServiceManager](/dotnet/api/microsoft.azure.devices.serviceclient) class exposes all methods required to create a backend application to send messages to devices.
138+
The [ServiceClient](/dotnet/api/microsoft.azure.devices.serviceclient) class exposes all methods required to create a backend application to send messages to devices.
144139

145140
### Required service NuGet package
146141

@@ -179,7 +174,7 @@ To invoke a method on a device:
179174
1. Create a [CloudToDeviceMethod](/dotnet/api/microsoft.azure.devices.cloudtodevicemethod) object. Pass the device direct method name as a parameter.
180175
1. Call [InvokeDeviceMethodAsync](/dotnet/api/microsoft.azure.devices.serviceclient.invokedevicemethodasync?#microsoft-azure-devices-serviceclient-invokedevicemethodasync(system-string-microsoft-azure-devices-cloudtodevicemethod-system-threading-cancellationtoken)) to invoke the method on the device.
181176

182-
This example calls the "reboot" method to initiate a reboot on the device. The "reboot" method is mapped to a listener on the device as described in the **Create a direct method callback** section above.
177+
This example calls the "reboot" method to initiate a reboot on the device. The "reboot" method is mapped to a listener on the device as described in the **Create a direct method callback** section of this article.
183178

184179
```csharp
185180
CloudToDeviceMethod method = new CloudToDeviceMethod("reboot");
@@ -193,7 +188,7 @@ client.InvokeDeviceMethodAsync(targetDevice, method);
193188
Console.WriteLine("Invoked firmware update on device.");
194189
```
195190

196-
This example gets the device twin for the rebooting device and outputs the reported properties. This output shows that the `onReboot` method callback has updated the `lastReboot`, `Reboot`, and `iothubDM` reported properties.
191+
This example gets the device twin for the rebooting device and outputs the reported properties. This output shows that the `onReboot` callback method updated the `lastReboot`, `Reboot`, and `iothubDM` reported properties.
197192

198193
```csharp
199194
public static async Task QueryTwinRebootReported()

0 commit comments

Comments
 (0)