다음을 통해 공유


Scripts.ReplaceTriggerAsync Method

Definition

Replaces a TriggerProperties in the Azure Cosmos service as an asynchronous operation.

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.Scripts.TriggerResponse> ReplaceTriggerAsync (Microsoft.Azure.Cosmos.Scripts.TriggerProperties triggerProperties, Microsoft.Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReplaceTriggerAsync : Microsoft.Azure.Cosmos.Scripts.TriggerProperties * Microsoft.Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.Scripts.TriggerResponse>
Public MustOverride Function ReplaceTriggerAsync (triggerProperties As TriggerProperties, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TriggerResponse)

Parameters

triggerProperties
TriggerProperties

The TriggerProperties object.

requestOptions
RequestOptions

(Optional) The options for the trigger request.

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

A Task containing a TriggerResponse which wraps a TriggerProperties containing the updated resource record.

Exceptions

If triggerProperties is not set.

Examples

This examples replaces an existing trigger.

TriggerProperties triggerProperties = new TriggerProperties
{
    Id = "testTriggerId",
    Body = @"function AddTax() {
        var item = getContext().getRequest().getBody();

        // Validate/calculate the tax.
        item.tax = item.cost* .15;

        // Update the request -- this is what is going to be inserted.
        getContext().getRequest().setBody(item);
    }",
    TriggerOperation = TriggerOperation.All,
    TriggerType = TriggerType.Post
};

Scripts scripts = this.container.Scripts;
TriggerResponse response = await scripts.ReplaceTriggerAsync(triggerSettigs);

Applies to