Azure Cosmos DB output from Azure Stream Analytics

Azure Cosmos DB is a globally distributed database service that offers limitless elastic scale around the globe, rich query, and automatic indexing over schema-agnostic data models. To learn about Azure Cosmos DB container options for Stream Analytics, see the Stream Analytics with Azure Cosmos DB as output article.

Azure Cosmos DB output from Stream Analytics is currently not available in Microsoft Azure operated by 21Vianet and Azure Germany (T-Systems International).

Note

Azure Stream Analytics only supports connection to Azure Cosmos DB by using the SQL API. Other Azure Cosmos DB APIs are not yet supported. If you point Azure Stream Analytics to the Azure Cosmos DB accounts created with other APIs, the data might not be properly stored.

The following table describes the properties for creating an Azure Cosmos DB output.

Property name Description
Output alias An alias to refer this output in your Stream Analytics query.
Sink Azure Cosmos DB.
Import option Choose either Select Azure Cosmos DB from your subscription or Provide Azure Cosmos DB settings manually.
Account ID The name or endpoint URI of the Azure Cosmos DB account.
Account key The shared access key for the Azure Cosmos DB account.
Database The Azure Cosmos DB database name.
Container name The container name to be used, which must exist in Azure Cosmos DB. Example:
  • MyContainer: A container named "MyContainer" must exist.
Document ID Optional. The name of the field in output events that's used to specify the primary key on which insert or update operations are based.

Note

Azure Cosmos DB Output for Azure Stream Analytics uses .NET V3 SDK. When writing to multiple regions, the SDK automatically picks the best region available.

Partitioning

The partition key is based on the PARTITION BY clause in the query. The number of output writers follows the input partitioning for fully parallelized queries. Stream Analytics converts the Azure Cosmos DB output partition key to a string. For example, if you have a partition key with a value of 1 of type bigint, it is converted to "1" of type string. This conversion always happens regardless of whether the partition property is written to Azure Cosmos DB.

Output batch size

For the maximum message size, see Azure Cosmos DB limits. Batch size and write frequency are adjusted dynamically based on Azure Cosmos DB responses. There are no predetermined limitations from Stream Analytics.

Next steps