DocumentClient.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 = null);
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>>
override this.CreatePermissionAsync : string * Microsoft.Azure.Documents.Permission * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.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.

Implements

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

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 = null);
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>>
override this.CreatePermissionAsync : Uri * Microsoft.Azure.Documents.Permission * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>>

Parameters

userUri
Uri

the URI of the user to create the permission for.

permission
Permission

the Microsoft.Azure.Documents.Permission object.

options
RequestOptions

The request options for the request.

Returns

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

Implements

Applies to