Scripts.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<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
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
Azure SDK for .NET