Udostępnij za pośrednictwem


TwinsClient.UpdateAsync Method

Definition

Overloads

UpdateAsync(IEnumerable<ClientTwin>, Boolean, CancellationToken)

Update the mutable fields for a list of module twins previously created within the system.

UpdateAsync(String, ClientTwin, Boolean, CancellationToken)

Updates the mutable fields of a module's twin.

UpdateAsync(String, String, ClientTwin, Boolean, CancellationToken)

Updates the mutable fields of a module's twin.

UpdateAsync(IEnumerable<ClientTwin>, Boolean, CancellationToken)

Update the mutable fields for a list of module twins previously created within the system.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.BulkRegistryOperationResult> UpdateAsync (System.Collections.Generic.IEnumerable<Microsoft.Azure.Devices.ClientTwin> twins, bool onlyIfUnchanged = false, System.Threading.CancellationToken cancellationToken = default);
abstract member UpdateAsync : seq<Microsoft.Azure.Devices.ClientTwin> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.BulkRegistryOperationResult>
override this.UpdateAsync : seq<Microsoft.Azure.Devices.ClientTwin> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.BulkRegistryOperationResult>
Public Overridable Function UpdateAsync (twins As IEnumerable(Of ClientTwin), Optional onlyIfUnchanged As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of BulkRegistryOperationResult)

Parameters

twins
IEnumerable<ClientTwin>

List of ClientTwins with updated fields.

onlyIfUnchanged
Boolean

If false, this operation will be performed even if the provided device identity has an out of date ETag. If true, the operation will throw a IotHubServiceException with PreconditionFailed if the provided device identity has an out of date ETag. An up-to-date ETag can be retrieved using GetAsync(String, String, CancellationToken).

cancellationToken
CancellationToken

Task cancellation token.

Returns

updated module twin.

Exceptions

When the provided twins is null.

When the provided twins enumeration is empty.

When a twin is missing an expected ETag.

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

UpdateAsync(String, ClientTwin, Boolean, CancellationToken)

Updates the mutable fields of a module's twin.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin> UpdateAsync (string deviceId, Microsoft.Azure.Devices.ClientTwin twinPatch, bool onlyIfUnchanged = false, System.Threading.CancellationToken cancellationToken = default);
abstract member UpdateAsync : string * Microsoft.Azure.Devices.ClientTwin * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
override this.UpdateAsync : string * Microsoft.Azure.Devices.ClientTwin * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
Public Overridable Function UpdateAsync (deviceId As String, twinPatch As ClientTwin, Optional onlyIfUnchanged As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ClientTwin)

Parameters

deviceId
String

The device Id.

twinPatch
ClientTwin

Twin with updated fields.

onlyIfUnchanged
Boolean

If false, this operation will be performed even if the provided device identity has an out of date ETag. If true, the operation will throw a IotHubServiceException with PreconditionFailed if the provided device identity has an out of date ETag. An up-to-date ETag can be retrieved using GetAsync(String, String, CancellationToken).

cancellationToken
CancellationToken

Task cancellation token.

Returns

Updated device twin.

Exceptions

When the provided deviceId or twinPatch is null.

If the deviceId 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

UpdateAsync(String, String, ClientTwin, Boolean, CancellationToken)

Updates the mutable fields of a module's twin.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin> UpdateAsync (string deviceId, string moduleId, Microsoft.Azure.Devices.ClientTwin twinPatch, bool onlyIfUnchanged = false, System.Threading.CancellationToken cancellationToken = default);
abstract member UpdateAsync : string * string * Microsoft.Azure.Devices.ClientTwin * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
override this.UpdateAsync : string * string * Microsoft.Azure.Devices.ClientTwin * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
Public Overridable Function UpdateAsync (deviceId As String, moduleId As String, twinPatch As ClientTwin, Optional onlyIfUnchanged As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ClientTwin)

Parameters

deviceId
String

The device Id.

moduleId
String

The module Id.

twinPatch
ClientTwin

Twin with updated fields.

onlyIfUnchanged
Boolean

If false, this operation will be performed even if the provided device identity has an out of date ETag. If true, the operation will throw a IotHubServiceException with PreconditionFailed if the provided device/module identity has an out of date ETag. An up-to-date ETag can be retrieved using GetAsync(String, String, CancellationToken).

cancellationToken
CancellationToken

Task cancellation token.

Returns

Updated device twin.

Exceptions

When the provided deviceId, moduleId, or twinPatch is null.

If the deviceId or moduleId 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