DocumentClient.UpsertDocumentAsync
Method
Definition
Overloads
| UpsertDocumentAsync(String, Object, RequestOptions, Boolean) |
Upserts a Document as an asychronous operation in the Azure DocumentDB database service. |
| UpsertDocumentAsync(Uri, Object, RequestOptions, Boolean) |
Upserts a document as an asychronous operation in the Azure DocumentDB database service. |
UpsertDocumentAsync(String, Object, RequestOptions, Boolean)
Upserts a Document as an asychronous operation in the Azure DocumentDB database service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>> UpsertDocumentAsync (string documentsFeedOrDatabaseLink, object document, Microsoft.Azure.Documents.Client.RequestOptions options = null, bool disableAutomaticIdGeneration = false);
- documentsFeedOrDatabaseLink
- String
The link of the DocumentCollection to upsert the document in. E.g. dbs/db_rid/colls/coll_rid/
- document
- Object
The document object to upsert.
- options
- RequestOptions
(Optional) Any request options you wish to set. E.g. Specifying a Trigger to execute when creating the document. RequestOptions
- disableAutomaticIdGeneration
- Boolean
(Optional) Disables the automatic id generation, If this is True the system will throw an exception if the id property is missing from the Document.
The Document that was upserted contained within a Task object representing the service response for the asynchronous operation.
If either documentsFeedOrDatabaseLink or document 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:
| StatusCode | Reason for exception |
|---|---|
| 400 | BadRequest - This means something was wrong with the document supplied. It is likely that disableAutomaticIdGeneration was true and an id was not supplied |
| 403 | Forbidden - This likely means the collection in to which you were trying to upsert the document is full. |
| 409 | Conflict - This means a Document with an id matching the id field of document already existed |
| 413 | RequestEntityTooLarge - This means the Document exceeds the current max entity size. Consult documentation for limits and quotas. |
| 429 | TooManyRequests - This means you have exceeded the number of request units per second. Consult the DocumentClientException.RetryAfter value to see how long you should wait before retrying this operation. |
UpsertDocumentAsync(Uri, Object, RequestOptions, Boolean)
Upserts a document as an asychronous operation in the Azure DocumentDB database service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>> UpsertDocumentAsync (Uri documentCollectionUri, object document, Microsoft.Azure.Documents.Client.RequestOptions options = null, bool disableAutomaticIdGeneration = false);
- documentCollectionUri
- Uri
the URI of the document collection to upsert the document in.
- document
- Object
the document object.
- options
- RequestOptions
The request options for the request.
- disableAutomaticIdGeneration
- Boolean
Disables the automatic id generation, will throw an exception if id is missing.
The task object representing the service response for the asynchronous operation.