共用方式為


DigitalTwinsClient.CreateOrReplaceEventRouteAsync Method

Definition

Creates an event route asynchronously. If the provided event route Id is already in use, then this will attempt to replace the existing event route with the provided event route.

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

Parameters

eventRouteId
String

The Id of the event route to create.

eventRoute
DigitalTwinsEventRoute

The event route data containing the endpoint and optional filter.

cancellationToken
CancellationToken

The cancellation token.

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 eventRouteId is null.

Examples

string eventFilter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'";
var eventRoute = new DigitalTwinsEventRoute(eventhubEndpointName, eventFilter);

await client.CreateOrReplaceEventRouteAsync(_eventRouteId, eventRoute);
Console.WriteLine($"Created event route '{_eventRouteId}'.");

Remarks

For more samples, see our repo samples.

Applies to

See also