IDocumentClient.ReplaceStoredProcedureAsync Method

Definition

Overloads

ReplaceStoredProcedureAsync(Uri, StoredProcedure, RequestOptions)

Replace the specified stored procedure in the Azure Cosmos DB service.

ReplaceStoredProcedureAsync(StoredProcedure, RequestOptions)

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

ReplaceStoredProcedureAsync(Uri, StoredProcedure, RequestOptions)

Replace the specified stored procedure in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.StoredProcedure>> ReplaceStoredProcedureAsync (Uri storedProcedureUri, Microsoft.Azure.Documents.StoredProcedure storedProcedure, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplaceStoredProcedureAsync : Uri * Microsoft.Azure.Documents.StoredProcedure * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.StoredProcedure>>
Public Function ReplaceStoredProcedureAsync (storedProcedureUri As Uri, storedProcedure As StoredProcedure, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of StoredProcedure))

Parameters

storedProcedureUri
Uri

The URI for the stored procedure to be updated.

storedProcedure
StoredProcedure

The updated stored procedure.

options
RequestOptions

(Optional) The RequestOptions for the request.

Returns

The task object representing the service response for the asynchronous operation.

Applies to

ReplaceStoredProcedureAsync(StoredProcedure, RequestOptions)

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

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.StoredProcedure>> ReplaceStoredProcedureAsync (Microsoft.Azure.Documents.StoredProcedure storedProcedure, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplaceStoredProcedureAsync : Microsoft.Azure.Documents.StoredProcedure * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.StoredProcedure>>
Public Function ReplaceStoredProcedureAsync (storedProcedure As StoredProcedure, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of StoredProcedure))

Parameters

storedProcedure
StoredProcedure

The updated StoredProcedure to replace the existing resource with.

options
RequestOptions

(Optional) The request options for the request.

Returns

A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a StoredProcedure containing the updated resource record.

Exceptions

If storedProcedure 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

//Fetch the resource to be updated
StoredProcedure sproc = client.CreateStoredProcedureQuery(sprocsLink)
                                 .Where(r => r.Id == "sproc id")
                                 .AsEnumerable()
                                 .SingleOrDefault();

//Update some properties on the found resource
sproc.Body = "function () {new javascript body for sproc}";

//Now persist these changes to the database by replacing the original resource
StoredProcedure updated = await client.ReplaceStoredProcedureAsync(sproc);

See also

Applies to