DocumentClient.ReplaceUserDefinedFunctionAsync Method

Definition

Overloads

ReplaceUserDefinedFunctionAsync(UserDefinedFunction, RequestOptions)

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

ReplaceUserDefinedFunctionAsync(Uri, UserDefinedFunction, RequestOptions)

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

ReplaceUserDefinedFunctionAsync(UserDefinedFunction, RequestOptions)

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

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

Parameters

function
UserDefinedFunction

The updated UserDefinedFunction to replace the existing resource with.

options
RequestOptions

(Optional) The request options for the request.

Returns

Task<ResourceResponse<UserDefinedFunction>>

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

Implements

Exceptions

If function 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
UserDefinedFunction udf = client.CreateUserDefinedFunctionQuery(functionsLink)
                                    .Where(r =&gt; r.Id == "udf id")    
                                    .AsEnumerable()
                                    .SingleOrDefault();

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

//Now persist these changes to the database by replacing the original resource
UserDefinedFunction updated = await client.ReplaceUserDefinedFunctionAsync(udf);

See also

Applies to

Product Introduced

ReplaceUserDefinedFunctionAsync(Uri, UserDefinedFunction, RequestOptions)

Replaces 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>> ReplaceUserDefinedFunctionAsync (Uri userDefinedFunctionUri, Microsoft.Azure.Documents.UserDefinedFunction function, Microsoft.Azure.Documents.Client.RequestOptions options = null);
abstract member ReplaceUserDefinedFunctionAsync : 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.ReplaceUserDefinedFunctionAsync : 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 ReplaceUserDefinedFunctionAsync (userDefinedFunctionUri As Uri, function As UserDefinedFunction, Optional options As RequestOptions = null) As Task(Of ResourceResponse(Of UserDefinedFunction))

Parameters

userDefinedFunctionUri
Uri

the URI for the user defined function to be updated.

function
UserDefinedFunction

the updated user defined function.

options
RequestOptions

The request options for the request.

Returns

Task<ResourceResponse<UserDefinedFunction>>

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

Implements

Applies to

Product Introduced