DocumentClient.CreateDocumentCollectionIfNotExistsAsync
Method
Definition
Overloads
| CreateDocumentCollectionIfNotExistsAsync(Uri, DocumentCollection, RequestOptions) |
Creates(if doesn't exist) or gets(if already exists) a collection as an asychronous operation in the Azure DocumentDB database service. |
| CreateDocumentCollectionIfNotExistsAsync(String, DocumentCollection, RequestOptions) |
Creates(if doesn't exist) or gets(if already exists) a collection as an asychronous operation in the Azure DocumentDB database service. You can check the status code from the response to determine whether the collection was newly created(201) or existing collection was returned(200). |
CreateDocumentCollectionIfNotExistsAsync(Uri, DocumentCollection, RequestOptions)
Creates(if doesn't exist) or gets(if already exists) a collection as an asychronous operation in the Azure DocumentDB database service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>> CreateDocumentCollectionIfNotExistsAsync (Uri databaseUri, Microsoft.Azure.Documents.DocumentCollection documentCollection, Microsoft.Azure.Documents.Client.RequestOptions options = null);
- databaseUri
- Uri
the URI of the database to create the collection in.
- documentCollection
- DocumentCollection
The DocumentCollection object.
- options
- RequestOptions
(Optional) Any RequestOptions you wish to provide when creating a Collection. E.g. RequestOptions.OfferThroughput = 400.
The DocumentCollection that was created contained within a Task object representing the service response for the asynchronous operation.
CreateDocumentCollectionIfNotExistsAsync(String, DocumentCollection, RequestOptions)
Creates(if doesn't exist) or gets(if already exists) a collection as an asychronous operation in the Azure DocumentDB database service. You can check the status code from the response to determine whether the collection was newly created(201) or existing collection was returned(200).
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.DocumentCollection>> CreateDocumentCollectionIfNotExistsAsync (string databaseLink, Microsoft.Azure.Documents.DocumentCollection documentCollection, Microsoft.Azure.Documents.Client.RequestOptions options = null);
- databaseLink
- String
The link of the database to create the collection in. E.g. dbs/db_rid/.
- documentCollection
- DocumentCollection
The DocumentCollection object.
- options
- RequestOptions
(Optional) Any RequestOptions you wish to provide when creating a Collection. E.g. RequestOptions.OfferThroughput = 400.
The DocumentCollection that was created contained within a Task object representing the service response for the asynchronous operation.
If either databaseLink or documentCollection 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 DocumentCollection are:
| StatusCode | Reason for exception |
|---|---|
| 400 | BadRequest - This means something was wrong with the request supplied. It is likely that an id was not supplied for the new collection. |
| 403 | Forbidden - This means you attempted to exceed your quota for collections. Contact support to have this quota increased. |