IDocumentClient.ReadAttachmentFeedAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ReadAttachmentFeedAsync(String, FeedOptions, CancellationToken) |
Reads the feed (sequence) of Attachment for a document from the Azure Cosmos DB service as an asynchronous operation. |
ReadAttachmentFeedAsync(Uri, FeedOptions, CancellationToken) |
Reads the feed (sequence) of attachments for a document as an asynchronous operation in the Azure Cosmos DB service. |
ReadAttachmentFeedAsync(String, FeedOptions, CancellationToken)
Reads the feed (sequence) of Attachment for a document from the Azure Cosmos DB service as an asynchronous operation.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Attachment>> ReadAttachmentFeedAsync (string attachmentsLink, Microsoft.Azure.Documents.Client.FeedOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadAttachmentFeedAsync : string * Microsoft.Azure.Documents.Client.FeedOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Attachment>>
Public Function ReadAttachmentFeedAsync (attachmentsLink As String, Optional options As FeedOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of FeedResponse(Of Attachment))
Parameters
- attachmentsLink
- String
The SelfLink of the resources to be read. E.g. /dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/
- options
- FeedOptions
(Optional) The request options for the request.
- cancellationToken
- CancellationToken
(Optional) A CancellationToken that can be used by other objects or threads to receive notice of cancellation.
Returns
A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a Attachment containing the read resource record.
Exceptions
If attachmentsLink
is not set.
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 |
---|---|
404 | NotFound - This means the resource feed you tried to read did not exist. Check the parent rids are correct. |
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. |
Examples
int count = 0;
string continuation = string.Empty;
do
{
// Read Attachment feed 10 items at a time until there are no more to read
FeedResponse<Attachment> response = await client.ReadAttachmentFeedAsync("/dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/ ",
new FeedOptions
{
MaxItemCount = 10,
RequestContinuation = continuation
});
// Append the item count
count += response.Count;
// Get the continuation so that we know when to stop.
continuation = response.ResponseContinuation;
} while (!string.IsNullOrEmpty(continuation));
See also
Applies to
ReadAttachmentFeedAsync(Uri, FeedOptions, CancellationToken)
Reads the feed (sequence) of attachments for a document as an asynchronous operation in the Azure Cosmos DB service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Attachment>> ReadAttachmentFeedAsync (Uri documentUri, Microsoft.Azure.Documents.Client.FeedOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadAttachmentFeedAsync : Uri * Microsoft.Azure.Documents.Client.FeedOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Attachment>>
Public Function ReadAttachmentFeedAsync (documentUri As Uri, Optional options As FeedOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of FeedResponse(Of Attachment))
Parameters
- documentUri
- Uri
The URI of the parent document.
- options
- FeedOptions
(Optional) The FeedOptions for the request.
- cancellationToken
- CancellationToken
(Optional) A CancellationToken that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the service response for the asynchronous operation.