Attachments in Azure Cosmos DB for NoSQL

Azure Cosmos DB for NoSQL attachments are special items that contain references to an associated metadata with a blob or media file.

Warning

Attachments in Azure Cosmos DB for NoSQL is a legacy feature. The current support is scoped only to offer continued functionlaity for existing users. For new workloads, it is recommended to store data in Azure Storage and reference it using URIs or other metadata in Azure Cosmos DB for NoSQL.

Types of attachments

Azure Cosmos DB supports two types of attachments:

  • Managed
    • These attachments are blobs managed and stored internally by Azure Cosmos DB and exposed via a system-generated mediaLink.
  • Unmanaged (recommended)
    • These attachments are a wrapper around a URI reference to a blob that is stored in an external service (for example, Azure Storage, OneDrive, etc.). This approach is similar to storing a URI property in a standard Azure Cosmos DB item.

Known limitations

Azure Cosmos DB’s managed attachments are distinct from its support for standard items – for which it offers unlimited scalability, global distribution, and integration with other Azure services.

  • Attachments aren't supported in all versions of the Azure Cosmos DB software development kits (SDKs).
  • Managed attachments are limited to 2 GB of storage per database account.
  • Managed attachments aren't compatible with Azure Cosmos DB’s global distribution, and they aren't replicated across regions.

Warning

Azure Cosmos DB for MongoDB version 3.2 utilizes managed attachments for GridFS and these are subject to the same limitations.

We recommend developers using the MongoDB GridFS feature set to upgrade to Azure Cosmos DB for MongoDB version 3.6 or higher, which is decoupled from attachments and provides a better experience. Alternatively, developers using the MongoDB GridFS feature set should also consider using Azure Blob Storage. Azure Blob Storage is purpose-built for storing blob content and offers expanded functionality at lower cost compared to GridFS.