DigitalTwinsClient.UpdateComponentAsync Method

Definition

Updates properties of a component on a digital twin asynchronously.

public virtual System.Threading.Tasks.Task<Azure.Response> UpdateComponentAsync (string digitalTwinId, string componentName, Azure.JsonPatchDocument jsonPatchDocument, Azure.ETag? ifMatch = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpdateComponentAsync : string * string * Azure.JsonPatchDocument * Nullable<Azure.ETag> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
override this.UpdateComponentAsync : string * string * Azure.JsonPatchDocument * Nullable<Azure.ETag> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function UpdateComponentAsync (digitalTwinId As String, componentName As String, jsonPatchDocument As JsonPatchDocument, Optional ifMatch As Nullable(Of ETag) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)

Parameters

digitalTwinId
System.String

The Id of the digital twin.

componentName
System.String

The component being modified.

jsonPatchDocument
JsonPatchDocument

The application/json-patch+json operations to be performed on the specified digital twin's component.

ifMatch
System.Nullable<ETag>

Optional. Only perform the operation if the entity's ETag matches this optional ETag or * (All) is provided.

cancellationToken
System.Threading.CancellationToken

The cancellation token.

Returns

System.Threading.Tasks.Task<Response>

The HTTP response Response<T>.

Exceptions

The exception that captures the errors from the service. Check the ErrorCode and Status properties for more details.

Examples

// Update Component1 by replacing the property ComponentProp1 value,
// using an optional utility to build the payload.
var componentJsonPatchDocument = new JsonPatchDocument();
componentJsonPatchDocument.AppendReplace("/ComponentProp1", "Some new value");
await client.UpdateComponentAsync(basicDtId, "Component1", componentJsonPatchDocument);
Console.WriteLine($"Updated component for digital twin '{basicDtId}'.");

Remarks

For more samples, see our repo samples.

Applies to