DocumentClient.ReadUserDefinedFunctionAsync 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
ReadUserDefinedFunctionAsync(String, RequestOptions) |
Reads a UserDefinedFunction from the Azure Cosmos DB service as an asynchronous operation. |
ReadUserDefinedFunctionAsync(Uri, RequestOptions) |
Reads a UserDefinedFunction as an asynchronous operation from the Azure Cosmos DB service. |
ReadUserDefinedFunctionAsync(String, RequestOptions)
Reads a UserDefinedFunction from the Azure Cosmos DB service as an asynchronous operation.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>> ReadUserDefinedFunctionAsync (string functionLink, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReadUserDefinedFunctionAsync : string * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>>
override this.ReadUserDefinedFunctionAsync : string * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>>
Public Function ReadUserDefinedFunctionAsync (functionLink As String, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of UserDefinedFunction))
Parameters
- functionLink
- String
The link to the User Defined Function to be read.
- options
- RequestOptions
(Optional) The request options for the request.
Returns
A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a UserDefinedFunction containing the read resource record.
Implements
Exceptions
If functionLink
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 you tried to read did not exist. |
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
//Reads a User Defined Function from a Database and DocumentCollection where
// - sample_database is the ID of the database
// - sample_collection is the ID of the collection
// - udf_id is the ID of the user-defined function to be read
var udfLink = "/dbs/sample_database/colls/sample_collection/udfs/udf_id";
UserDefinedFunction udf = await client.ReadUserDefinedFunctionAsync(udfLink);
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.
The example shown uses ID-based links, where the link is composed of the ID properties used when the resources were created. You can still use the SelfLink property of the User Defined Function if you prefer. A self-link is a URI for a resource that is made up of Resource Identifiers (or the _rid properties). ID-based links and SelfLink will both work. The format for functionLink
is always "/dbs/{db identifier}/colls/{coll identifier}/udfs/{udf identifier}" only the values within the {...} change depending on which method you wish to use to address the resource.
See also
Applies to
ReadUserDefinedFunctionAsync(Uri, RequestOptions)
Reads a UserDefinedFunction as an asynchronous operation from the Azure Cosmos DB service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>> ReadUserDefinedFunctionAsync (Uri functionUri, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReadUserDefinedFunctionAsync : Uri * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>>
override this.ReadUserDefinedFunctionAsync : Uri * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.UserDefinedFunction>>
Public Function ReadUserDefinedFunctionAsync (functionUri As Uri, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of UserDefinedFunction))
Parameters
- functionUri
- Uri
A URI to the User Defined Function resource to be read.
- options
- RequestOptions
The request options for the request.
Returns
A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a UserDefinedFunction containing the read resource record.
Implements
Exceptions
If functionUri
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 you tried to read did not exist. |
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
//Reads a UserDefinedFunction resource where
// - db_id is the ID property of the Database
// - coll_id is the ID property of the DocumentCollection
// - udf_id is the ID property of the UserDefinedFunction you wish to read.
var udfLink = UriFactory.CreateUserDefinedFunctionUri("db_id", "coll_id", "udf_id");
UserDefinedFunction udf = await client.ReadUserDefinedFunctionAsync(udfLink);
Remarks
Doing a read of a resource is the most efficient way to get a resource from the service. If you know the resource's ID, do a read instead of a query by ID.