DocumentClient.UpsertUserDefinedFunctionAsync Method

Definition

Overloads

UpsertUserDefinedFunctionAsync(Uri, UserDefinedFunction, RequestOptions)

Upserts a user defined function as an asynchronous operation in the Azure Cosmos DB service.

UpsertUserDefinedFunctionAsync(String, UserDefinedFunction, RequestOptions)

Upserts a user defined function as an asychronous operation in the Azure Cosmos DB service.

UpsertUserDefinedFunctionAsync(Uri, UserDefinedFunction, RequestOptions)

Upserts a user defined function as an asynchronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>> UpsertUserDefinedFunctionAsync (Uri documentCollectionUri, Microsoft.Azure.Documents.UserDefinedFunction function, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member UpsertUserDefinedFunctionAsync : Uri * Microsoft.Azure.Documents.UserDefinedFunction * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>>
override this.UpsertUserDefinedFunctionAsync : Uri * Microsoft.Azure.Documents.UserDefinedFunction * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>>
Public Function UpsertUserDefinedFunctionAsync (documentCollectionUri As Uri, function As UserDefinedFunction, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of UserDefinedFunction))

Parameters

documentCollectionUri
Uri

the URI of the document collection to upsert the user defined function in.

function
UserDefinedFunction

the Microsoft.Azure.Documents.UserDefinedFunction object.

options
RequestOptions

The request options for the request.

Returns

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

Implements

Applies to

UpsertUserDefinedFunctionAsync(String, UserDefinedFunction, RequestOptions)

Upserts a user defined function as an asychronous operation in the Azure Cosmos DB service.

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

Parameters

collectionLink
String

The link of the DocumentCollection to upsert the user defined function in. E.g. dbs/db_rid/colls/col_rid/

function
UserDefinedFunction

The UserDefinedFunction object to upsert.

options
RequestOptions

(Optional) Any RequestOptionsfor this request.

Returns

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

Implements

Exceptions

If either collectionLink or function 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 new user defined function or that the Body was malformed.
403Forbidden - You have reached your quota of user defined functions for the collection supplied. Contact support to have this quota increased.
409Conflict - This means a UserDefinedFunction with an id matching the id you supplied already existed.
413RequestEntityTooLarge - This means the body of the UserDefinedFunction you tried to upsert was too large.

Examples

//Upsert a user defined function that converts a string to upper case
UserDefinedFunction udf = client.UpsertUserDefinedFunctionAsync(collectionLink, new UserDefinedFunction
{
   Id = "ToUpper",
   Body = @"function toUpper(input) {
                       return input.toUpperCase();
                    }",
});

See also

Applies to