Share via


CosmosScripts.ReplaceUserDefinedFunctionAsync Method

Definition

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

public abstract System.Threading.Tasks.Task<Azure.Response<Azure.Cosmos.Scripts.UserDefinedFunctionProperties>> ReplaceUserDefinedFunctionAsync (Azure.Cosmos.Scripts.UserDefinedFunctionProperties userDefinedFunctionProperties, Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReplaceUserDefinedFunctionAsync : Azure.Cosmos.Scripts.UserDefinedFunctionProperties * Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Cosmos.Scripts.UserDefinedFunctionProperties>>
Public MustOverride Function ReplaceUserDefinedFunctionAsync (userDefinedFunctionProperties As UserDefinedFunctionProperties, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of UserDefinedFunctionProperties))

Parameters

userDefinedFunctionProperties
UserDefinedFunctionProperties

The UserDefinedFunctionProperties object.

requestOptions
RequestOptions

(Optional) The options for the user defined function request RequestOptions

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

A Task containing a Response<T> which wraps a UserDefinedFunctionProperties containing the updated resource record.

Examples

This examples replaces an existing user defined function.

CosmosScripts scripts = this.container.Scripts;
UserDefinedFunctionProperties udfProperties = new UserDefinedFunctionProperties
{
    Id = "testUserDefinedFunId",
    Body = "function(amt) { return amt * 0.15; }",
};

Response<UserDefinedFunctionProperties> response = await scripts.ReplaceUserDefinedFunctionAsync(udfProperties);
UserDefinedFunctionProperties udfProperties = response;

Applies to