Table of Contents

Class UriFactory

Namespace
Microsoft.Azure.Documents.Client
Assembly
Microsoft.Azure.Documents.Client.dll

Helper class to assist in creating the various Uris needed for use with the DocumentClient instance in the Azure Cosmos DB service.

public static class UriFactory
Inheritance
UriFactory
Inherited Members

Examples

The example below uses UriFactory to create a DocumentCollectionLink and then uses that to create a Document.

Uri collUri = UriFactory.CreateDocumentCollectionUri("MyDb", "MyCollection");
var doc = await client.CreateDocumentAsync(collUri, new {id = "MyDoc"});

Methods

CreateAttachmentUri(string, string, string, string)

Given a database, collection, document, and attachment id, this creates an attachment link.

public static Uri CreateAttachmentUri(string databaseId, string collectionId, string documentId, string attachmentId)

Parameters

databaseId string

The database id

collectionId string

The collection id

documentId string

The document id

attachmentId string

The attachment id

Returns

Uri

An attachment link in the format of /dbs/{0}/colls/{1}/docs/{2}/attachments/{3} with {0} being a Uri escaped version of the databaseId, {1} being collectionId, {2} being the documentId and {3} being attachmentId

Remarks

Would be used when replacing, or deleting an Attachment in Azure Cosmos DB.

See Also

CreateCollectionUri(string, string)

Given a database and collection id, this creates a collection link.

[Obsolete("CreateCollectionUri method is deprecated, please use CreateDocumentCollectionUri method instead.")]
public static Uri CreateCollectionUri(string databaseId, string collectionId)

Parameters

databaseId string

The database id

collectionId string

The collection id

Returns

Uri

A collection link in the format of /dbs/{0}/colls/{1}/ with {0} being a Uri escaped version of the databaseId and {1} being collectionId

Remarks

Would be used when updating or deleting a DocumentCollection, creating a Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query with CreateDocumentQuery in Azure Cosmos DB.

See Also

CreateConflictUri(string, string, string)

Given a database, collection and conflict id, this creates a conflict link.

public static Uri CreateConflictUri(string databaseId, string collectionId, string conflictId)

Parameters

databaseId string

The database id

collectionId string

The collection id

conflictId string

The conflict id

Returns

Uri

A conflict link in the format of /dbs/{0}/colls/{1}/conflicts/{2}/ with {0} being a Uri escaped version of the databaseId, {1} being collectionId and {2} being the conflictId

Remarks

Would be used when creating a Conflict in Azure Cosmos DB.

See Also

CreateDatabaseUri(string)

Given a database id, this creates a database link.

public static Uri CreateDatabaseUri(string databaseId)

Parameters

databaseId string

The database id

Returns

Uri

A database link in the format of /dbs/{0}/ with {0} being a Uri escaped version of the databaseId

Remarks

Would be used when creating or deleting a DocumentCollection or a User in Azure Cosmos DB.

See Also

CreateDocumentCollectionUri(string, string)

Given a database and collection id, this creates a collection link.

public static Uri CreateDocumentCollectionUri(string databaseId, string collectionId)

Parameters

databaseId string

The database id

collectionId string

The collection id

Returns

Uri

A collection link in the format of /dbs/{0}/colls/{1}/ with {0} being a Uri escaped version of the databaseId and {1} being collectionId

Remarks

Would be used when updating or deleting a DocumentCollection, creating a Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query with CreateDocumentQuery in Azure Cosmos DB.

See Also

CreateDocumentUri(string, string, string)

Given a database, collection and document id, this creates a document link.

public static Uri CreateDocumentUri(string databaseId, string collectionId, string documentId)

Parameters

databaseId string

The database id

collectionId string

The collection id

documentId string

The document id

Returns

Uri

A document link in the format of /dbs/{0}/colls/{1}/docs/{2}/ with {0} being a Uri escaped version of the databaseId, {1} being collectionId and {2} being the documentId

Remarks

Would be used when creating an Attachment, or when replacing or deleting a Document in Azure Cosmos DB.

See Also

CreatePartitionKeyRangesUri(string, string)

Given a database and collection, this creates a partition key ranges link in the Azure Cosmos DB service.

public static Uri CreatePartitionKeyRangesUri(string databaseId, string collectionId)

Parameters

databaseId string

The database id

collectionId string

The collection id

Returns

Uri

A partition key ranges link in the format of /dbs/{0}/colls/{1}/pkranges with {0} being a Uri escaped version of the databaseId and {1} being collectionId.

See Also

CreatePermissionUri(string, string, string)

Given a database and user id, this creates a permission link.

public static Uri CreatePermissionUri(string databaseId, string userId, string permissionId)

Parameters

databaseId string

The database id

userId string

The user id

permissionId string

The permission id

Returns

Uri

A permission link in the format of /dbs/{0}/users/{1}/permissions/{2} with {0} being a Uri escaped version of the databaseId, {1} being userId and {2} being permissionId

Remarks

Would be used when replacing or deleting a Permission in Azure Cosmos DB.

See Also

CreateStoredProcedureUri(string, string, string)

Given a database, collection and stored proc id, this creates a stored proc link.

public static Uri CreateStoredProcedureUri(string databaseId, string collectionId, string storedProcedureId)

Parameters

databaseId string

The database id

collectionId string

The collection id

storedProcedureId string

The stored procedure id

Returns

Uri

A stored procedure link in the format of /dbs/{0}/colls/{1}/sprocs/{2}/ with {0} being a Uri escaped version of the databaseId, {1} being collectionId and {2} being the storedProcedureId

Remarks

Would be used when replacing, executing, or deleting a StoredProcedure in Azure Cosmos DB.

See Also

CreateTriggerUri(string, string, string)

Given a database, collection and trigger id, this creates a trigger link.

public static Uri CreateTriggerUri(string databaseId, string collectionId, string triggerId)

Parameters

databaseId string

The database id

collectionId string

The collection id

triggerId string

The trigger id

Returns

Uri

A trigger link in the format of /dbs/{0}/colls/{1}/triggers/{2}/ with {0} being a Uri escaped version of the databaseId, {1} being collectionId and {2} being the triggerId

Remarks

Would be used when replacing, executing, or deleting a Trigger in Azure Cosmos DB.

See Also

CreateUserDefinedFunctionUri(string, string, string)

Given a database, collection and udf id, this creates a udf link.

public static Uri CreateUserDefinedFunctionUri(string databaseId, string collectionId, string udfId)

Parameters

databaseId string

The database id

collectionId string

The collection id

udfId string

The udf id

Returns

Uri

A udf link in the format of /dbs/{0}/colls/{1}/udfs/{2}/ with {0} being a Uri escaped version of the databaseId, {1} being collectionId and {2} being the udfId

Remarks

Would be used when replacing, executing, or deleting a UserDefinedFunction in Azure Cosmos DB.

See Also

CreateUserUri(string, string)

Given a database and user id, this creates a user link.

public static Uri CreateUserUri(string databaseId, string userId)

Parameters

databaseId string

The database id

userId string

The user id

Returns

Uri

A user link in the format of /dbs/{0}/users/{1}/ with {0} being a Uri escaped version of the databaseId and {1} being userId

Remarks

Would be used when creating a Permission, or when replacing or deleting a User in Azure Cosmos DB.

See Also