DocumentClient.CreateDatabaseIfNotExistsAsync Method

Definition

Creates(if doesn't exist) or gets(if already exists) a database resource as an asychronous operation in the Azure DocumentDB database service. You can check the status code from the response to determine whether the database was newly created(201) or existing database was returned(200)

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Database>> CreateDatabaseIfNotExistsAsync (Microsoft.Azure.Documents.Database database, Microsoft.Azure.Documents.Client.RequestOptions options = null);
Parameters
database
Database

The specification for the Database to create.

options
RequestOptions

(Optional) The RequestOptions for the request.

Returns

The Database that was created within a task object representing the service response for the asynchronous operation.

Exceptions

If database 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.