CosmosScripts.ReplaceStoredProcedureAsync Method

Definition

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

public abstract System.Threading.Tasks.Task<Azure.Response<Azure.Cosmos.Scripts.StoredProcedureProperties>> ReplaceStoredProcedureAsync (Azure.Cosmos.Scripts.StoredProcedureProperties storedProcedureProperties, Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReplaceStoredProcedureAsync : Azure.Cosmos.Scripts.StoredProcedureProperties * Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Cosmos.Scripts.StoredProcedureProperties>>
Public MustOverride Function ReplaceStoredProcedureAsync (storedProcedureProperties As StoredProcedureProperties, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of StoredProcedureProperties))

Parameters

storedProcedureProperties
StoredProcedureProperties

The Stored Procedure to replace

requestOptions
RequestOptions

(Optional) The options for the stored procedure request StoredProcedureRequestOptions

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

A Task containing a StoredProcedureProperties.

Exceptions

If storedProcedureProperties 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:

StatusCodeReason for exception
404NotFound - This means the resource you tried to delete did not exist.

Examples

This examples replaces an existing stored procedure.

//Updated body
string 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);
}";

CosmosScripts scripts = this.container.Scripts;
Response<StoredProcedureProperties> response = await scripts.ReplaceStoredProcedureAsync(new StoredProcedureProperties("testTriggerId", body));

Applies to