Skip to content

Commit 581e0a4

Browse files
committed
Metadata and links updated, minor rewording and Acrolinx fixes to improve score
1 parent 8835531 commit 581e0a4

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

articles/iot-hub/iot-hub-devguide-direct-methods.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: SoniaLopezBravo
66
ms.author: sonialopez
77
ms.service: azure-iot-hub
88
ms.topic: concept-article
9-
ms.date: 05/03/2024
9+
ms.date: 03/20/2025
1010
ms.custom: [amqp, mqtt,'Role: Cloud Development', 'Role: IoT Device']
1111
---
1212

@@ -18,27 +18,27 @@ IoT Hub *direct methods* enable you to remotely invoke calls on devices from the
1818

1919
Each device method targets a single device. If you want to invoke direct methods on multiple devices, or schedule methods for disconnected devices, see [Schedule jobs on multiple devices](iot-hub-devguide-jobs.md).
2020

21-
Anyone with **service connect** permissions on IoT Hub may invoke a method on a device.
21+
Anyone with **service connect** permissions on IoT Hub can invoke a method on a device.
2222

23-
Refer to the [Cloud-to-device communication guidance](iot-hub-devguide-c2d-guidance.md) if in doubt between using desired properties, direct methods, or cloud-to-device messages.
23+
Refer to the [Cloud-to-device communications guidance](iot-hub-devguide-c2d-guidance.md) if in doubt between using desired properties, direct methods, or cloud-to-device messages.
2424

2525
## Method lifecycle
2626

27-
Direct methods are implemented on the device and may require zero or more inputs in the method payload to correctly instantiate. You invoke a direct method through a service-facing URI (`{iot hub}/twins/{device id}/methods/`). A device receives direct methods through a device-specific MQTT topic (`$iothub/methods/POST/{method name}/`) or through AMQP links (the `IoThub-methodname` and `IoThub-status` application properties).
27+
Direct methods are implemented on the device and might require zero or more inputs in the method payload to correctly instantiate. You invoke a direct method through a service-facing URI (`{iot hub}/twins/{device id}/methods/`). A device receives direct methods through a device-specific MQTT topic (`$iothub/methods/POST/{method name}/`) or through AMQP links (the `IoThub-methodname` and `IoThub-status` application properties).
2828

2929
> [!NOTE]
3030
> When you invoke a direct method on a device, property names and values can only contain US-ASCII printable alphanumeric, except any in the following set: `$ ( ) < > @ , ; : \ " / [ ] ? = { } SP HT`
3131
>
3232
33-
Direct methods are synchronous and either succeed or fail after the timeout period (default 30 seconds; settable between 5 and 300 seconds). Direct methods are useful in interactive scenarios where you want a device to act if and only if the device is online and receiving commands. For example, turning on a light from a phone. In these scenarios, you want to see an immediate success or failure so the cloud service can act on the result as soon as possible. The device may return some message body as a result of the method, but it isn't required. There is no guarantee on ordering or any concurrency semantics on method calls.
33+
Direct methods are synchronous and either succeed or fail after the time-out period (default 30 seconds; settable between 5 and 300 seconds). Direct methods are useful in interactive scenarios where you want a device to act if and only if the device is online and receiving commands. For example, turning on a light from a phone. In these scenarios, you want to see an immediate success or failure so the cloud service can act on the result as soon as possible. The device might return some message body as a result of the method, but it isn't required. There's no guarantee on ordering or any concurrency semantics on method calls.
3434

3535
Direct methods are HTTPS-only from the cloud side and MQTT, AMQP, MQTT over WebSockets, or AMQP over WebSockets from the device side.
3636

3737
The payload for method requests and responses is a JSON document up to 128 KB.
3838

3939
## Invoke a direct method from a back-end app
4040

41-
To invoke a direct method from a back-end app use the [Invoke device method](/rest/api/iothub/service/devices/invoke-method) REST API or its equivalent in one of the [IoT Hub service SDKs](iot-hub-devguide-sdks.md#azure-iot-hub-service-sdks).
41+
To invoke a direct method from a back-end app, use the [Devices - Invoke Method](/rest/api/iothub/service/devices/invoke-method) REST API or its equivalent in one of the [IoT Hub service SDKs](iot-hub-devguide-sdks.md#azure-iot-hub-service-sdks).
4242

4343
### Method invocation
4444

@@ -68,7 +68,7 @@ Direct method invocations on a device are HTTPS calls that are made up of the fo
6868
}
6969
```
7070
71-
The value provided as `responseTimeoutInSeconds` in the request is the amount of time that IoT Hub service must await for completion of a direct method execution on a device. Set this timeout to be at least as long as the expected execution time of a direct method by a device. If timeout is not provided, the default value of 30 seconds is used. The minimum and maximum values for `responseTimeoutInSeconds` are 5 and 300 seconds, respectively.
71+
The value provided as `responseTimeoutInSeconds` in the request is the amount of time that IoT Hub service must await for completion of a direct method execution on a device. Set this time-out to be at least as long as the expected execution time of a direct method by a device. If a time-out value isn't provided, the default value of 30 seconds is used. The minimum and maximum values for `responseTimeoutInSeconds` are 5 and 300 seconds, respectively.
7272
7373
The value provided as `connectTimeoutInSeconds` in the request is the amount of time upon invocation of a direct method that IoT Hub service must await for a disconnected device to come online. The default value is 0, meaning that devices must already be online upon invocation of a direct method. The maximum value for `connectTimeoutInSeconds` is 300 seconds.
7474
@@ -82,7 +82,7 @@ To begin, use the [Microsoft Azure IoT extension for Azure CLI](https://github.c
8282
az iot hub generate-sas-token -n <iothubName> --du <duration>
8383
```
8484

85-
Next, replace the Authorization header with your newly generated SharedAccessSignature, then modify the `iothubName`, `deviceId`, `methodName` and `payload` parameters to match your implementation in the example `curl` command below.
85+
Next, replace the Authorization header with your newly generated SharedAccessSignature, then modify the `iothubName`, `deviceId`, `methodName`, and `payload` parameters to match your implementation in the following example `curl` command.
8686

8787
```bash
8888
curl -X POST \
@@ -102,7 +102,7 @@ curl -X POST \
102102
Execute the modified command to invoke the specified direct method. Successful requests return an HTTP 200 status code.
103103

104104
> [!NOTE]
105-
> The example above demonstrates invoking a direct method on a device. If you want to invoke a direct method in an IoT Edge Module, modify the url request to include `/modules/<moduleName>` as shown below:
105+
> The previous example demonstrates invoking a direct method on a device. If you want to invoke a direct method in an IoT Edge module, modify the URL request to include `/modules/<moduleName>` as shown in the following example:
106106
>
107107
> ```bash
108108
> https://<iothubName>.azure-devices.net/twins/<deviceId>/modules/<moduleName>/methods?api-version=2021-04-12
@@ -114,8 +114,8 @@ The back-end app receives a response that is made up of the following items:
114114
115115
* *HTTP status code*:
116116
* 200 indicates successful execution of direct method;
117-
* 404 indicates that either device ID is invalid, or that the device was not online upon invocation of a direct method and for `connectTimeoutInSeconds` thereafter (use accompanied error message to understand the root cause);
118-
* 504 indicates gateway timeout caused by device not responding to a direct method call within `responseTimeoutInSeconds`.
117+
* 404 indicates that either device ID is invalid, or that the device wasn't online upon invocation of a direct method and for `connectTimeoutInSeconds` thereafter (use accompanied error message to understand the root cause);
118+
* 504 indicates gateway time-out caused by device not responding to a direct method call within `responseTimeoutInSeconds`.
119119
120120
* *Headers* that contain the request ID, content type, and content encoding.
121121
@@ -132,7 +132,7 @@ The back-end app receives a response that is made up of the following items:
132132
133133
### Method invocation for IoT Edge modules
134134
135-
Invoking direct methods on a module is supported by the [Invoke module method](/rest/api/iothub/service/modules/invoke-method) REST API or its equivalent in one of the IoT Hub service SDKs.
135+
To invoke a direct method on a module, use the [Modules - Invoke Method](/rest/api/iothub/service/modules/invoke-method) REST API or its equivalent in one of the [IoT Hub service SDKs](iot-hub-devguide-sdks.md#azure-iot-hub-service-sdks).
136136
137137
The `moduleId` is passed along with the `deviceId` in the request URI when using the REST API or as a parameter when using a service SDK. For example, `https://<iothubName>.azure-devices.net/twins/<deviceId>/modules/<moduleName>/methods?api-version=2021-04-12`. The request body and response is similar to that of direct methods invoked on the device.
138138
@@ -142,11 +142,11 @@ On an IoT device, direct methods can be received over MQTT, AMQP, or either of t
142142
143143
### MQTT
144144
145-
The following section is for the MQTT protocol. To learn more about using the MQTT protocol directly with IoT Hub, see [MQTT protocol support](../iot/iot-mqtt-connect-to-iot-hub.md).
145+
The following section is for the MQTT protocol. To learn more about using the MQTT protocol directly with IoT Hub, see [Communicate with an IoT hub using the MQTT protocol](../iot/iot-mqtt-connect-to-iot-hub.md).
146146
147147
#### Method invocation
148148
149-
Devices receive direct method requests on the MQTT topic: `$iothub/methods/POST/{method name}/?$rid={request id}`. However, the `request id` is generated by IoT Hub and cannot be known ahead of time, so subscribe to `$iothub/methods/POST/#` and then filter the delivered messages based on method names supported by your device. (You'll use the `request id` to respond.)
149+
Devices receive direct method requests on the MQTT topic: `$iothub/methods/POST/{method name}/?$rid={request id}`. However, the `request id` can't be known ahead of time because IoT Hub generates it, so subscribe to `$iothub/methods/POST/#` and then filter the delivered messages based on method names supported by your device. (You use the generated `request id` to respond.)
150150
151151
The body that the device receives is in the following format:
152152
@@ -167,11 +167,11 @@ The device sends responses to `$iothub/methods/res/{status}/?$rid={request id}`,
167167
168168
* The `$rid` property is the request ID from the method invocation received from IoT Hub. The request ID is a hexadecimal formatted value.
169169
170-
The body is set by the device and can be any status.
170+
The device sets the body and can be any status.
171171
172172
### AMQP
173173
174-
The following section is for the AMQP protocol. To learn more about using the AMQP protocol directly with IoT Hub, see [AMQP protocol support](iot-hub-amqp-support.md).
174+
The following section is for the AMQP protocol. To learn more about using the AMQP protocol directly with IoT Hub, see [Communicate with your IoT hub by using the AMQP Protocol](iot-hub-amqp-support.md).
175175
176176
#### Method invocation
177177
@@ -199,9 +199,9 @@ The method's response is returned on the sending link and is structured as follo
199199
200200
## Next steps
201201
202-
Now you have learned how to use direct methods, you may be interested in the following IoT Hub developer guide article:
202+
Now that you know how to use direct methods, you might be interested in the following IoT Hub developer guide articles:
203203
204204
* [Schedule jobs on multiple devices](iot-hub-devguide-jobs.md)
205-
* [Azure IoT device and service SDKs](iot-hub-devguide-sdks.md) lists the various language SDKs you can use when you develop both device and service apps that interact with IoT Hub.
206-
* [IoT Hub query language for device twins, jobs, and message routing](iot-hub-devguide-query-language.md) describes the IoT Hub query language you can use to retrieve information from IoT Hub about your device twins and jobs.
205+
* [Azure IoT Hub SDKs](iot-hub-devguide-sdks.md) lists the various language SDKs you can use when you develop both device and service apps that interact with IoT Hub.
206+
* [IoT Hub query language for device and module twins, jobs, and message routing](iot-hub-devguide-query-language.md) describes the IoT Hub query language you can use to retrieve information from IoT Hub about your device twins and jobs.
207207

includes/iot-hub-basic-whole.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
author: SoniaLopezBravo
66
ms.service: azure-iot-hub
77
ms.topic: include
8-
ms.date: 04/01/2018
8+
ms.date: 03/20/2025
99
ms.author: sonialopez
1010
ms.custom: include file
1111
---
1212
>[!NOTE]
13-
>The features described in this article are available only in the standard tier of IoT Hub. For more information about the basic and standard/free IoT Hub tiers, see [Choose the right IoT Hub tier for your solution](../articles/iot-hub/iot-hub-scaling.md).
13+
>The features described in this article are available only in the standard tier of IoT Hub. For more information about the basic and standard/free IoT Hub tiers, see [Choose the right IoT Hub tier and size for your solution](../articles/iot-hub/iot-hub-scaling.md).

0 commit comments

Comments
 (0)