Share via


DigitalTwinsClient.DeleteModelAsync(String, CancellationToken) Method

Definition

Deletes a model asynchronously.

public virtual System.Threading.Tasks.Task<Azure.Response> DeleteModelAsync (string modelId, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteModelAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
override this.DeleteModelAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function DeleteModelAsync (modelId As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)

Parameters

modelId
String

The id for the model. The id is globally unique and case sensitive.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

The HTTP response Response.

Exceptions

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

The exception is thrown when modelId is null.

Examples

try
{
    await client.DeleteModelAsync(sampleModelId);
    Console.WriteLine($"Deleted model '{sampleModelId}'.");
}
catch (Exception ex)
{
    FatalError($"Failed to delete model '{sampleModelId}' due to:\n{ex}");
}

Remarks

A model can only be deleted if no other models reference it. Status codes: 204 (No Content): Success. 400 (Bad Request): The request is invalid. 404 (Not Found): There is no model with the provided id. 409 (Conflict): There are dependencies on the model that prevent it from being deleted.

For more samples, see our repo samples.

Applies to

See also