IDocumentClient.UpsertUserDefinedFunctionAsync 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
UpsertUserDefinedFunctionAsync(Uri, UserDefinedFunction, RequestOptions) |
Upserts a user defined function as an asychronous 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 asychronous 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>>
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 UserDefinedFunction object.
- options
- RequestOptions
(Optional) The RequestOptions for the request.
Returns
The task object representing the service response for the asynchronous operation.
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>>
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.
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:
StatusCode | Reason for exception |
---|---|
400 | BadRequest - 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. |
403 | Forbidden - You have reached your quota of user defined functions for the collection supplied. Contact support to have this quota increased. |
409 | Conflict - This means a UserDefinedFunction with an id matching the id you supplied already existed. |
413 | RequestEntityTooLarge - 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();
}",
});