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 [ScheduleDeviceMethodAsync](/dotnet/api/microsoft.azure.devices.jobclient.scheduledevicemethodasync) to create a job to run a direct method on one or multiple devices.
65
+
Use [ScheduleDeviceMethodAsync](/dotnet/api/microsoft.azure.devices.jobclient.scheduledevicemethodasync) to schedule a job to run a direct method on one or multiple devices.
66
66
67
-
This example schedules a job for a direct method method named "LockDoor" on one device named "Device-1". The device(s) included in the scheduled job are contained second parameter as a query condition.
67
+
The [CloudToDeviceMethod](/dotnet/api/microsoft.azure.devices.cloudtodevicemethod.-ctor?#microsoft-azure-devices-cloudtodevicemethod-ctor(system-string-system-timespan-system-timespan)) object to specify the direct method name and device connection timeout values.
68
68
69
69
```csharp
70
-
stringmethodJobId=Guid.NewGuid().ToString(); // a unique job ID
71
-
staticstringdeviceId="Device-1"; // In this example, there is only one device affected.
72
-
73
-
// The CloudToDeviceMethod record specifies the direct method name and device connection timeout.
70
+
// The CloudToDeviceMethod record specifies the direct method name and device connection timeout
This example schedules a job for a direct method method named "LockDoor" on one device named "Device-1". The device(s) included in the scheduled job are contained second parameter as a query condition.
77
77
78
+
```csharp
79
+
stringmethodJobId=Guid.NewGuid().ToString(); // a unique job ID
80
+
staticstringdeviceId="Device-1"; // In this example, there is only one device affected
Use [ScheduleTwinUpdateAsync](/dotnet/api/microsoft.azure.devices.jobclient.scheduledevicemethodasync) to create a new desired twin update job to run on one or multiple devices.
90
-
91
-
First, create and populate a device `Twin` object for the update.
90
+
Use [ScheduleTwinUpdateAsync](/dotnet/api/microsoft.azure.devices.jobclient.scheduledevicemethodasync) to schedule a new desired twin update job to run on one or multiple devices.
92
91
93
-
For example:
92
+
First, create and populate a device `Twin` object for the update. For example:
Use [GetJobAsync](/dotnet/api/microsoft.azure.devices.jobclient.getjobasync?#microsoft-azure-devices-jobclient-getjobasync(system-string)) to monitor a job status.
120
+
Use [GetJobAsync](/dotnet/api/microsoft.azure.devices.jobclient.getjobasync?#microsoft-azure-devices-jobclient-getjobasync(system-string)) to monitor the job status for a specific job ID.
122
121
123
-
This example checks the job status for a job ID periodically until the job is complete or failed.
122
+
This example checks the job status for a job ID periodically until the job status is complete or failed. For example:
This article describes how to use the [Azure IoT SDK for Java](https://github.com/Azure/azure-iot-sdk-java) to create backend service application code to schedule job to invoke a direct method or perform a device twin desired property update on one or more devices.
19
19
20
-
The [JobClient](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient) class contains methods that services can use to schedule jobs.
21
-
22
20
### Service import statements
23
21
22
+
The [JobClient](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient) class contains methods that services can use to schedule jobs.
23
+
24
24
Use the following service import statements to access the Azure IoT SDK for Java.
25
25
26
26
```java
@@ -67,18 +67,18 @@ JobClient jobClient = new JobClient(iotHubConnectionString);
Use [scheduleDeviceMethod](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient?#com-microsoft-azure-sdk-iot-service-jobs-jobclient-scheduledevicemethod(java-lang-string-java-lang-string-java-lang-string-java-lang-long-java-lang-long-java-lang-object-java-util-date-long)) to run a direct method on one or multiple devices.
73
73
74
-
This example method schedules a direct method call job for a specific job ID.
74
+
This example method schedules a job for a direct method named "lockDoor" on a device named "Device-1".
75
75
76
76
```java
77
77
// Schedule a job now to call the lockDoor direct method
78
78
// against a single device. Response and connection
79
79
// timeouts are set to 5 seconds.
80
80
String deviceId ="Device-1";
81
-
String jobId ="DMCMD"+UUID.randomUUID();
81
+
String jobId ="DMCMD"+UUID.randomUUID();//Job ID must be unique
82
82
83
83
// How long the job is permitted to run without
84
84
// completing its work on the set of devices
@@ -100,21 +100,14 @@ try {
100
100
101
101
### Schedule a device twin update job
102
102
103
-
Use [scheduleUpdateTwin](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient?#com-microsoft-azure-sdk-iot-service-jobs-jobclient-scheduleupdatetwin(java-lang-string-java-lang-string-com-microsoft-azure-sdk-iot-service-devicetwin-devicetwindevice-java-util-date-long)) to create a new job to run a device twin update on one or multiple devices.
103
+
Use [scheduleUpdateTwin](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient?#com-microsoft-azure-sdk-iot-service-jobs-jobclient-scheduleupdatetwin(java-lang-string-java-lang-string-com-microsoft-azure-sdk-iot-service-devicetwin-devicetwindevice-java-util-date-long)) to schedule a job to run a device twin update on one or multiple devices.
104
104
105
105
This example method schedules a device twin update job for a specific job Id.
106
106
107
-
First, prepare a `DeviceTwinDevice` record.
108
-
109
-
For example:
107
+
First, prepare a `DeviceTwinDevice` record for the device twin update. For example:
Use [queryDeviceJob](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient?#com-microsoft-azure-sdk-iot-service-jobs-jobclient-querydevicejob(java-lang-string)) to query a job status.
176
+
Use [queryDeviceJob](/java/api/com.microsoft.azure.sdk.iot.service.jobs.jobclient?#com-microsoft-azure-sdk-iot-service-jobs-jobclient-querydevicejob(java-lang-string)) to query the job status for one or more jobs.
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-schedule-broadcast-jobs-node.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,9 +59,9 @@ var jobClient = JobClient.fromConnectionString(connectionString);
59
59
60
60
### Create a direct method update job
61
61
62
-
Use [scheduleDeviceMethod](/javascript/api/azure-iothub/jobclient?#azure-iothub-jobclient-scheduledevicemethod) to create a new direct method job to run a direct method on one or multiple devices.
62
+
Use [scheduleDeviceMethod](/javascript/api/azure-iothub/jobclient?#azure-iothub-jobclient-scheduledevicemethod) to schedule a job to run a direct method on one or multiple devices.
63
63
64
-
First, create a direct method update variable.
64
+
First, create a direct method update variable with method name, payload, and response timeout information. For example:
65
65
66
66
```javascript
67
67
var methodParams = {
@@ -71,12 +71,14 @@ var methodParams = {
71
71
};
72
72
```
73
73
74
-
Call`scheduleDeviceMethod` to schedule the direct method call job:
74
+
Then call`scheduleDeviceMethod` to schedule the direct method call job:
75
75
76
76
* Each job must have a unique job ID. You can use this job ID to monitor a job as described in the **Monitor a job** section of this article.
77
77
* Specify a `queryCondition` parameter to evaluate which devices to run the job on.
78
78
* Check the `jobResult` callback for the job schedule result. If the job was successfully scheduled, you can monitor the job status as shown in the **Monitor a job** section of this article.
79
79
80
+
For example:
81
+
80
82
```javascript
81
83
var methodJobId =uuid.v4();
82
84
var queryCondition ="deviceId IN ['myDeviceId']";
@@ -121,12 +123,14 @@ var twinPatch = {
121
123
};
122
124
```
123
125
124
-
Call`scheduleTwinUpdate` to schedule the device twin desired property update job:
126
+
Then call`scheduleTwinUpdate` to schedule the device twin desired property update job:
125
127
126
128
* Each job must have a unique job ID. You can use this job ID to monitor a job as described in the **Monitor a job** section of this article.
127
129
* Specify a `queryCondition` parameter to evaluate which devices to run the job on.
128
130
* Check the `jobResult` callback for the job schedule result. If the job was successfully scheduled, you can monitor the job status as shown in the **Monitor a job** section of this article.
Use [create_scheduled_job](/python/api/azure-iot-hub/azure.iot.hub.iothubjobmanager?#azure-iot-hub-iothubjobmanager-create-scheduled-job) to create a new direct method to run a direct method on one or multiple devices:
77
+
Use [create_scheduled_job](/python/api/azure-iot-hub/azure.iot.hub.iothubjobmanager?#azure-iot-hub-iothubjobmanager-create-scheduled-job) to schedule a new direct method to run a direct method on one or multiple devices:
70
78
71
79
`create_scheduled_job` parameter notes:
72
80
73
81
*`job_id` must be unique
74
82
* Set `type` to `scheduleDeviceMethod`
75
83
* Use `cloud_to_device_method` to set the direct method name and payload
76
84
* Use `max_execution_time_in_seconds` to specify the execution time in seconds
77
-
* Use `query_condition` to specify a condition for one or more devices that have the direct method call.
85
+
* Use `query_condition` to specify the devices to be included for the direct method call
78
86
79
87
For example:
80
88
81
89
```python
82
90
METHOD_NAME="lockDoor"
83
91
METHOD_PAYLOAD="{\"lockTime\":\"10m\"}"
84
92
job_id = uuid.uuid4()
93
+
DEVICE_ID="Device-1"
85
94
TIMEOUT=60
86
95
87
96
job_request = JobRequest()
@@ -105,7 +114,7 @@ Use [create_scheduled_job](/python/api/azure-iot-hub/azure.iot.hub.iothubjobmana
105
114
* Set `type` to `scheduleUpdateTwin`
106
115
* Use `update_twin` to set the direct method name and payload
107
116
* Use `max_execution_time_in_seconds` to specify the execution time in seconds
108
-
* Use `query_condition` to specify a condition for one or more devices that have the direct method call.
117
+
* Use `query_condition` to specify a condition for one or more devices that have the direct method call
0 commit comments