Share via


Scripts.ReplaceUserDefinedFunctionAsync Method

Definition

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

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

Parameters

userDefinedFunctionProperties
UserDefinedFunctionProperties

The UserDefinedFunctionProperties object.

requestOptions
RequestOptions

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

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

A Task containing a UserDefinedFunctionResponse which wraps a UserDefinedFunctionProperties containing the updated resource record.

Examples

This examples replaces an existing user defined function.

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

UserDefinedFunctionResponse response = await scripts.ReplaceUserDefinedFunctionAsync(udfProperties);
UserDefinedFunctionProperties udfProperties = response;

Applies to