IDocumentClient.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.
Overloads
ReplaceTriggerAsync(Trigger, RequestOptions) |
Replaces a Trigger in the Azure Cosmos DB service as an asynchronous operation. |
ReplaceTriggerAsync(Uri, Trigger, RequestOptions) |
Replaces a trigger as an asynchronous operation in the Azure Cosmos DB service. |
ReplaceTriggerAsync(Trigger, RequestOptions)
Replaces a Trigger in the Azure Cosmos DB service as an asynchronous operation.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>> ReplaceTriggerAsync (Microsoft.Azure.Documents.Trigger trigger, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplaceTriggerAsync : Microsoft.Azure.Documents.Trigger * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>>
Public Function ReplaceTriggerAsync (trigger As Trigger, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Trigger))
Parameters
- options
- RequestOptions
(Optional) The request options for the request.
Returns
A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a Trigger containing the updated resource record.
Exceptions
If trigger
is not set.
This exception can encapsulate many different types of errors. To determine the specific error always look at the StatusCode property. Some common codes you may get when creating a Document are:
StatusCode | Reason for exception |
---|---|
404 | NotFound - This means the resource you tried to delete did not exist. |
Examples
//Fetch the resource to be updated
Trigger trigger = client.CreateTriggerQuery(sprocsLink)
.Where(r => r.Id == "trigger id")
.AsEnumerable()
.SingleOrDefault();
//Update some properties on the found resource
trigger.Body = "function () {new javascript body for trigger}";
//Now persist these changes to the database by replacing the original resource
Trigger updated = await client.ReplaceTriggerAsync(sproc);
See also
Applies to
ReplaceTriggerAsync(Uri, Trigger, RequestOptions)
Replaces a trigger as an asynchronous operation in the Azure Cosmos DB service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>> ReplaceTriggerAsync (Uri triggerUri, Microsoft.Azure.Documents.Trigger trigger, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplaceTriggerAsync : Uri * Microsoft.Azure.Documents.Trigger * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Trigger>>
Public Function ReplaceTriggerAsync (triggerUri As Uri, trigger As Trigger, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Trigger))
Parameters
- triggerUri
- Uri
The URI for the trigger to be updated.
- trigger
- Trigger
The updated trigger.
- options
- RequestOptions
(Optional) The RequestOptions for the request.
Returns
The task object representing the service response for the asynchronous operation.
Applies to
Azure SDK for .NET