Frequently asked questions about Azure Cosmos DB for NoSQL

APPLIES TO: NoSQL

General

How do I start developing against Azure Cosmos DB for NoSQL?

First you must sign up for an Azure subscription. Once you sign up for an Azure subscription, you can add an API for NoSQL container to your Azure subscription.

Software development kits (SDKs) are available for .NET, Python, Node.js, JavaScript, Go, and Java. Developers can also use the REST API to interact with Azure Cosmos DB resources from more platforms and languages.

Is there Azure Cosmos DB for NoSQL samples to get started?

Check out these QuickStart code samples and templates for the API for NoSQL:

Does Azure Cosmos DB for NoSQL support schema-free data?

Yes, the API for NoSQL allows applications to store arbitrary JSON documents as items without schema definitions or hints. The data is immediately available for query with the Azure Cosmos DB for NoSQL query language.

Does Azure Cosmos DB for NoSQL support ACID (atomicity, consistency, isolation, durability) transactions?

Yes, the API for NoSQL supports cross-document transactions expressed using either batches in the SDKs or as JavaScript-stored procedures and triggers. Transactions are scoped to a single partition within each container and executed with ACID semantics as "all or nothing," isolated from other concurrently executing code and user requests. If exceptions occur, the entire transaction is rolled back.

How do I create an Azure Cosmos DB for NoSQL database?

You can create databases by using one of these tools:

Can I authenticate to Azure Cosmos DB for NoSQL using my existing Microsoft Entra ID accounts?

Yes! Azure Cosmos DB supports Microsoft Entra authentication to manage the service and its resources (control-plane) and to execute data, operations, and queries (data-plane). Control-plane authentication is performed using the role-based access control feature of Azure. You can use a preconfigured built-in role](../../role-based-access-control/built-in-roles.md) or you can create a custom role. With Azure role-based access control, you can manage accounts, databases, containers, and metadata. The control-plane includes operations including, but not limited to these examples.

  • Creating, replacing, or deleting databases - Creating, replacing, or deleting containers - Reading or replacing database throughput - Reading or replacing container throughput Data-plane authentication uses a custom API for NoSQL-native role-based access control implementation. With this native implementation, you can also use preconfigured or custom roles. With native role-based access control, you can execute queries, manage items, or perform other common operations. The data-plane includes operations including, but not limited to these examples.
  • Creating, replacing, updating, or deleting items - Patching items - Executing queries

Does Azure Cosmos DB for NoSQL support the SQL query language?

Structured Query Language (SQL) is a language typically used to query relational data. The API for NoSQL has a custom NoSQL query language derived from SQL. The NoSQL query language includes a subset of the SQL query language typically associated with SQL Server along with various NoSQL-specific enhancements. The NoSQL query language provides rich hierarchical and relational operators and extensibility via JavaScript-based, user-defined functions (UDFs). JSON grammar allows for modeling JSON documents as trees with labeled nodes, which are used by both the Azure Cosmos DB automatic indexing techniques and the SQL query dialect of Azure Cosmos DB. For information about using this query language, see NoSQL Query.

Does Azure Cosmos DB for NoSQL support SQL aggregation functions?

The API for NoSQL supports aggregation via aggregate functions such as: COUNT, MAX, AVG, and SUM via the NoSQL query language.

How does Azure Cosmos DB for NoSQL provide concurrency?

The API for NoSQL supports optimistic concurrency control (OCC) through HTTP entity tags, or ETags. Every API for NoSQL resource has an ETag, and the ETag is set on the server every time a document is updated. The ETag header and the current value are included in all response messages. ETags can be used with the If-Match header to allow the server to decide whether a resource should be updated. The If-Match value is the ETag value to be checked against. If the ETag value matches the server ETag value, the resource is updated. If the ETag is no longer current, the server rejects the operation with an "HTTP 412 Precondition failure" response code. The client then refetches the resource to acquire the current ETag value for the resource. In addition, ETags can be used with the If-None-Match header to determine whether its needed to refetch a resource.

Most of the API for NoSQL SDKs includes classes to manage optimistic concurrency control.

How can I bulk-insert documents into Azure Cosmos DB for NoSQL?

Use the bulk import feature in the .NET SDK or the Java SDK for the API for NoSQL to import large sets of data. This feature optimizes provisioned throughput to import large sets of data.

Alternatively, use Apache Spark to import data at scale using Python or Scala.

Yes, because Azure Cosmos DB for NoSQL is a RESTful service, resource links are immutable and can be cached. API for NoSQL clients can specify an "If-None-Match" header for reads against any resource-like document or container and then update their local copies after the server version changes.

Is a local instance of Azure Cosmos DB for NoSQL available?

Yes. The Azure Cosmos DB emulator provides a high-fidelity emulation of the Azure Cosmos DB service. It supports functionality that's identical to Azure Cosmos DB across various APIs. This functionality includes support for creating items, querying items, provisioning containers, and scaling containers. You can develop and test applications by using the emulator's endpoints. You can then deploy the applications to Azure at a multiple-region scale by changing the connection string from the emulator to the live service.

Why are long floating-point values in an Azure Cosmos DB for NoSQL item rounded when using the Data Explorer in the portal?

This Data Explorer limitation is a limitation of JavaScript. JavaScript uses double-precision floating-point format numbers as specified in Institute of Electrical and Electronics Engineers (IEEE) 754. This data type can safely hold numbers between -(253 - 1) and 253-1 (that is, 9007199254740991) only.

Security

What is role-based access control (RBAC)?

Role-based access control (RBAC) is a method of regulating access to computer or network resources based on the roles of individual users within an enterprise. In Azure Cosmos DB, RBAC is used to grant data-plane access to users and applications. For more information about various terms in role-based access control, see the security glossary.

How do I enable data-plane role-based access control for Azure Cosmos DB for NoSQL?

Use the Azure Cosmos DB native role-based access control (RBAC) feature to grant data-plane access to users and applications. For more information, see Grant data-plane role-based access.

Which Azure Cosmos DB APIs support data-plane role-based access control?

As of now, only the NoSQL API is supported.

Is it possible to manage role definitions and role assignments from the Azure portal?

Azure portal support for role management isn't available yet.

Which SDKs in Azure Cosmos DB API for NoSQL support role-based access control?

The .NET V3, Java V4, JavaScript V3, and Python V4.3+ SDKs are currently supported.

Is the Microsoft Entra token automatically refreshed by the Azure Cosmos DB SDKs when it expires?

Yes.

Is it possible to disable the usage of the account primary/secondary keys when using role-based access control?

Yes. For more information, see disable key-based authentication.