Sdílet prostřednictvím


DocumentClient.ReadOfferAsync(String) Method

Definition

Reads an Offer from the Azure Cosmos DB service as an asynchronous operation.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Offer>> ReadOfferAsync (string offerLink);
abstract member ReadOfferAsync : string -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Offer>>
override this.ReadOfferAsync : string -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Offer>>
Public Function ReadOfferAsync (offerLink As String) As Task(Of ResourceResponse(Of Offer))

Parameters

offerLink
String

The link to the Offer to be read.

Returns

A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a Offer containing the read resource record.

Implements

Exceptions

If offerLink 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:

StatusCodeReason for exception
404NotFound - This means the resource you tried to read did not exist.
429TooManyRequests - 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

//Reads an Offer resource from a Database
// - offer_id is the ID of the offer to be read
var offerLink = "/offers/offer_id";
Offer offer = await client.ReadOfferAsync(offerLink);

Remarks

Doing a read of a resource is the most efficient way to get a resource from the Database. If you know the resource's ID, do a read instead of a query by ID.

For an Offer, id is always generated internally by the system when the linked resource is created. id and _rid are always the same for Offer.

Refer to https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-provision-container-throughput to learn more about minimum throughput of a Cosmos container (or a database) To retrieve the minimum throughput for a collection/database, use the following sample

// Find the offer for the collection by SelfLink
Offer offer = client.CreateOfferQuery(
    string.Format("SELECT * FROM offers o WHERE o.resource = '{0}'", collectionSelfLink)).AsEnumerable().FirstOrDefault();
ResourceResponse<Offer> response = await client.ReadOfferAsync(offer.SelfLink);
string minimumRUsForCollection = response.ResponseHeaders["x-ms-cosmos-min-throughput"];

Applies to

See also