Skip to main content

Azure Cosmos DB (SQL API)

Type: bindings.azure.cosmosdb

Status: stable

Reference: https://docs.dapr.io/reference/components-reference/supported-bindings/cosmosdb/

Example

apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
name: <name>
spec:
type: bindings.azure.cosmosdb
version: v1
metadata:
# The key to authenticate to the Cosmos DB account.
- name: masterKey
value: "my-secret-key"
# The name of the collection (container).
- name: collection
value: "Orders"
# The name of the database.
- name: database
value: "OrdersDB"
# The name of the key to extract from the payload (document to be created) that is used as the partition key. This name must match the partition key specified upon creation of the Cosmos DB container.
- name: partitionKey
value: "OrderId"
# The Cosmos DB url.
- name: url
value: "https://******.documents.azure.com:443/"

Binding information

Input Binding: no

Output Binding: yes

Output Binding operations:

  • create: Create an item

Authentication profiles

Available authentication profiles:

  • Master key

  • Azure AD: Client credentials

  • Azure AD: Client certificate

Master key

Authenticate using a pre-shared "master key".

masterKey

Required - The key to authenticate to the Cosmos DB account.

Example value: my-secret-key

Azure AD: Client credentials

Authenticate using Azure AD with client credentials, also known as "service principals".

azureClientId

Required - Client ID (application ID)

Example value: c7dd251f-811f-4ba2-a905-acd4d3f8f08b

azureClientSecret

Required - Client secret (application password)

Example value: Ecy3XG7zVZK3/vl/a2NSB+a1zXLa8RnMum/IgD0E

azureTenantId

Required - ID of the Azure AD tenant

Example value: cd4b2887-304c-47e1-b4d5-65447fdd542a

azureEnvironment

Optional name for the Azure environment if using a different Azure cloud

Default value: AzurePublicCloud

Example value: AzurePublicCloud

Allowed values:

  • AzurePublicCloud

  • AzureChinaCloud

  • AzureUSGovernmentCloud

Azure AD: Client certificate

Authenticate using Azure AD with a client certificate. "azureCertificate" is required.

azureClientId

Required - Client ID (application ID)

Example value: c7dd251f-811f-4ba2-a905-acd4d3f8f08b

azureTenantId

Required - ID of the Azure AD tenant

Example value: cd4b2887-304c-47e1-b4d5-65447fdd542a

azureCertificate

Certificate and private key (in either a PEM file containing both the certificate and key, or in PFX/PKCS#12 format)

Example value:

-----BEGIN PRIVATE KEY-----\n MIIEvgI... \n -----END PRIVATE KEY-----
\n -----BEGIN CERTIFICATE----- \n MIICoTC... \n -----END CERTIFICATE----- \n

azureCertificatePassword

Password for the certificate if encrypted.

Example value: password

azureEnvironment

Optional name for the Azure environment if using a different Azure cloud

Default value: AzurePublicCloud

Example value: AzurePublicCloud

Allowed values:

  • AzurePublicCloud

  • AzureChinaCloud

  • AzureUSGovernmentCloud

Metadata

collection (string)

Required - The name of the collection (container).

Example value: Orders

database (string)

Required - The name of the database.

Example value: OrdersDB

partitionKey (string)

Required - The name of the key to extract from the payload (document to be created) that is used as the partition key. This name must match the partition key specified upon creation of the Cosmos DB container.

Example value: OrderId

url (string)

Required - The Cosmos DB url.

Example value: https://******.documents.azure.com:443/