Azure Cosmos DB (SDK)

Interact with Azure Cosmos DB using the official SDK (supports vector search and hybrid queries)

Create or Update

AI-generated

Summary

Upserts a document into an Azure Cosmos DB container: creates a new document if the ID does not exist, or updates the existing document if it does. The document must include an ID field and the container's partition key field.

Inputs

  • authenticationType — The authentication method to use. 'masterKey' uses the Cosmos DB master key; 'entraId' uses Microsoft Entra ID OAuth2. Default: masterKey.
  • databaseName (required) — The database to use. Can be selected from a list, searched, or provided by name or ID.
  • containerName (required) — The container to use. Can be selected from a list, searched, or provided by name or ID.
  • document (required) — The document to upsert as JSON. Must include an ID field and the container's partition key field. Default: {}.

Output shape

json

The upserted document resource as returned by the Cosmos DB SDK. If the SDK returns no resource, the original document is returned.

Examples

Example 1: Create a new document

authenticationType=masterKey, databaseName=myDb, containerName=myContainer, document={ ID: '123', name: 'Example', category: 'electronics' }

Links

Discussion