Udostępnij za pośrednictwem


IDocumentClient.CreatePermissionAsync Method

Definition

Overloads

CreatePermissionAsync(String, Permission, RequestOptions)

Creates a permission on a user object as an asychronous operation in the Azure Cosmos DB service.

CreatePermissionAsync(Uri, Permission, RequestOptions)

Creates a permission as an asychronous operation in the Azure Cosmos DB service.

CreatePermissionAsync(String, Permission, RequestOptions)

Creates a permission on a user object as an asychronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>> CreatePermissionAsync (string userLink, Microsoft.Azure.Documents.Permission permission, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member CreatePermissionAsync : string * Microsoft.Azure.Documents.Permission * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>>
Public Function CreatePermissionAsync (userLink As String, permission As Permission, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Permission))

Parameters

userLink
String

The link of the user to create the permission for. E.g. dbs/db_rid/users/user_rid/

permission
Permission

The Permission object.

options
RequestOptions

(Optional) The request options for the request.

Returns

A task object representing the service response for the asynchronous operation which contains the created Permission object.

Exceptions

If either userLink or permission 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:

StatusCodeReason for exception
400BadRequest - This means something was wrong with the request supplied.
403Forbidden - You have reached your quota of permission objects. Contact support to have this quota increased.
409Conflict - This means a Permission with an id matching the id you supplied already existed.

Examples

//Create a read-only permission object for a specific user
Permission p = await client.CreatePermissionAsync(userLink, new Permission { Id = "ReadPermission", PermissionMode = PermissionMode.Read });

See also

Applies to

CreatePermissionAsync(Uri, Permission, RequestOptions)

Creates a permission as an asychronous operation in the Azure Cosmos DB service.

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

Parameters

userUri
Uri

The URI of the user to create the permission for.

permission
Permission

The Permission object.

options
RequestOptions

(Optional) The RequestOptions for the request.

Returns

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

Applies to