Udostępnij za pośrednictwem


DocumentClient.UpsertStoredProcedureAsync Method

Definition

Overloads

UpsertStoredProcedureAsync(String, StoredProcedure, RequestOptions)

Upserts a stored procedure as an asychronous operation in the Azure Cosmos DB service.

UpsertStoredProcedureAsync(Uri, StoredProcedure, RequestOptions)

Upserts a stored procedure as an asynchronous operation in the Azure Cosmos DB service.

UpsertStoredProcedureAsync(String, StoredProcedure, RequestOptions)

Upserts a stored procedure as an asychronous operation in the Azure Cosmos DB service.

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

Parameters

collectionLink
String

The link of the collection to upsert the stored procedure in. E.g. dbs/db_rid/colls/col_rid/

storedProcedure
StoredProcedure

The StoredProcedure object to upsert.

options
RequestOptions

(Optional) Any RequestOptionsfor this request.

Returns

The StoredProcedure that was upserted contained within a Task object representing the service response for the asynchronous operation.

Implements

Exceptions

If either collectionLink or storedProcedure is not set.

Represents a consolidation of failures that occured during async processing. Look within InnerExceptions to find the actual exception(s)

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
400BadRequest - This means something was wrong with the request supplied. It is likely that an Id was not supplied for the stored procedure or the Body was malformed.
403Forbidden - You have reached your quota of stored procedures for the collection supplied. Contact support to have this quota increased.
409Conflict - This means a StoredProcedure with an id matching the id you supplied already existed.
413RequestEntityTooLarge - This means the body of the StoredProcedure you tried to upsert was too large.

Examples

//Upsert a new stored procedure called "HelloWorldSproc" that takes in a single param called "name".
StoredProcedure sproc = await client.UpsertStoredProcedureAsync(collectionLink, new StoredProcedure
{
   Id = "HelloWorldSproc",
   Body = @"function (name){
               var response = getContext().getResponse();
               response.setBody('Hello ' + name);
            }"
});

See also

Applies to

UpsertStoredProcedureAsync(Uri, StoredProcedure, RequestOptions)

Upserts a stored procedure as an asynchronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.StoredProcedure>> UpsertStoredProcedureAsync (Uri documentCollectionUri, Microsoft.Azure.Documents.StoredProcedure storedProcedure, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member UpsertStoredProcedureAsync : Uri * Microsoft.Azure.Documents.StoredProcedure * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.StoredProcedure>>
override this.UpsertStoredProcedureAsync : 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 UpsertStoredProcedureAsync (documentCollectionUri As Uri, storedProcedure As StoredProcedure, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of StoredProcedure))

Parameters

documentCollectionUri
Uri

the URI of the document collection to upsert the stored procedure in.

storedProcedure
StoredProcedure

the Microsoft.Azure.Documents.StoredProcedure object.

options
RequestOptions

The request options for the request.

Returns

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

Implements

Applies to