CosmosScripts.ReplaceTriggerAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Replaces a TriggerProperties in the Azure Cosmos service as an asynchronous operation.
public abstract System.Threading.Tasks.Task<Azure.Response<Azure.Cosmos.Scripts.TriggerProperties>> ReplaceTriggerAsync (Azure.Cosmos.Scripts.TriggerProperties triggerProperties, Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReplaceTriggerAsync : Azure.Cosmos.Scripts.TriggerProperties * Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Cosmos.Scripts.TriggerProperties>>
Public MustOverride Function ReplaceTriggerAsync (triggerProperties As TriggerProperties, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of TriggerProperties))
Parameters
- triggerProperties
- TriggerProperties
The TriggerProperties object.
- requestOptions
- RequestOptions
(Optional) The options for the trigger request RequestOptions
- cancellationToken
- CancellationToken
(Optional) CancellationToken representing request cancellation.
Returns
A Task containing a Response<T> 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
};
CosmosScripts scripts = this.container.Scripts;
Response<TriggerProperties> response = await scripts.ReplaceTriggerAsync(triggerSettigs);