Udostępnij za pośrednictwem


ScheduledJobsClient.ScheduleDirectMethodAsync Method

Definition

Creates a new job to run a device method on one or multiple devices.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.ScheduledJob> ScheduleDirectMethodAsync (string queryCondition, Microsoft.Azure.Devices.DirectMethodServiceRequest directMethodRequest, DateTimeOffset startOnUtc, Microsoft.Azure.Devices.ScheduledJobsOptions scheduledJobsOptions, System.Threading.CancellationToken cancellationToken = default);
abstract member ScheduleDirectMethodAsync : string * Microsoft.Azure.Devices.DirectMethodServiceRequest * DateTimeOffset * Microsoft.Azure.Devices.ScheduledJobsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ScheduledJob>
override this.ScheduleDirectMethodAsync : string * Microsoft.Azure.Devices.DirectMethodServiceRequest * DateTimeOffset * Microsoft.Azure.Devices.ScheduledJobsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ScheduledJob>
Public Overridable Function ScheduleDirectMethodAsync (queryCondition As String, directMethodRequest As DirectMethodServiceRequest, startOnUtc As DateTimeOffset, scheduledJobsOptions As ScheduledJobsOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ScheduledJob)

Parameters

queryCondition
String

Query condition to evaluate which devices the job applies to.

directMethodRequest
DirectMethodServiceRequest

Method call parameters.

startOnUtc
DateTimeOffset

When to start the job in UTC.

scheduledJobsOptions
ScheduledJobsOptions

Optional parameters for scheduled device method, i.e: scheduledJobsOptions.JobId.JobId and scheduledJobsOptions.MaxExecutionTimeInSeconds.MaxExecutionTimeInSeconds.

cancellationToken
CancellationToken

Task cancellation token.

Returns

A job object.

Exceptions

When the provided scheduledJobsOptions.JobId.JobId or queryCondition or startOnUtc is null.

If the scheduledJobsOptions.JobId.JobId or queryCondition is empty or white space.

If IoT hub responded to the request with a non-successful status code. For example, if the provided request was throttled, IotHubServiceException with ThrottlingException is thrown. For a complete list of possible error cases, see IotHubServiceErrorCode.

If the HTTP request fails due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the provided cancellationToken has requested cancellation.

Applies to