次の方法で共有


Scripts.ReplaceTriggerStreamAsync Method

Definition

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

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

Parameters

triggerProperties
TriggerProperties

The TriggerProperties object.

requestOptions
RequestOptions
cancellationToken
CancellationToken

Returns

A Task containing a ResponseMessagecontaining the updated resource record.

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;
ResponseMessage response = await scripts.ReplaceTriggerStreamAsync(triggerSettigs);
if (!response.IsSuccessStatusCode)
{
    //Handle and log exception
    return;
}

Applies to