IDocumentClient.ReplaceUserAsync Method

Definition

Overloads

ReplaceUserAsync(User, RequestOptions)

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

ReplaceUserAsync(Uri, User, RequestOptions)

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

ReplaceUserAsync(User, RequestOptions)

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

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.User>> ReplaceUserAsync (Microsoft.Azure.Documents.User user, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplaceUserAsync : Microsoft.Azure.Documents.User * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.User>>
Public Function ReplaceUserAsync (user As User, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of User))

Parameters

user
User

The updated User to replace the existing resource with.

options
RequestOptions

(Optional) The request options for the request.

Returns

Task<ResourceResponse<User>>

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

Exceptions

If user 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
User user = client.CreateUserQuery(usersLink)
                         .Where(r => r.Id == "user id")
                         .AsEnumerable()
                         .SingleOrDefault();

//Change the user mode to All
user.Id = "some new method";

//Now persist these changes to the database by replacing the original resource
User updated = await client.ReplaceUserAsync(user);

See also

Applies to

ReplaceUserAsync(Uri, User, RequestOptions)

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

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.User>> ReplaceUserAsync (Uri userUri, Microsoft.Azure.Documents.User user, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplaceUserAsync : Uri * Microsoft.Azure.Documents.User * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.User>>
Public Function ReplaceUserAsync (userUri As Uri, user As User, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of User))

Parameters

userUri
Uri

The URI for the user to be updated.

user
User

The updated user.

options
RequestOptions

(Optional) The RequestOptions for the request.

Returns

Task<ResourceResponse<User>>

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

Applies to