> For the complete documentation index, see [llms.txt](https://docs.adiom.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adiom.io/reference/connectors/cosmos-db-nosql.md).

# Cosmos DB NoSQL

The Cosmos DB NoSQL connector is supported both as a source and a destination. It runs as a separate gRPC service that dsync/dsynct connects to, using the Java SDK optimized for bulk operations.

## Running the Connector

Set the Cosmos DB account URL and key. These can be found under "Settings" -> "Keys" in the Azure Portal.

```bash
export COSMOS_URI="..."
export COSMOS_KEY="..."
```

```bash
docker run \
  --network mynet --name cosmosnosqlconnector \
  markadiom/cosmosnosqlconnector 8089 $COSMOS_URI $COSMOS_KEY
```

## gRPC Configuration

The connector exposes a gRPC endpoint. When specifying it as a source or destination, use the `grpc://` scheme with the `--insecure` flag (TLS is not enabled by default):

```
grpc://cosmosnosqlconnector:8089 --insecure
```

When running outside of Docker networking, replace the container name with the appropriate host (e.g. `grpc://localhost:8089`).

## Data Type

The Cosmos DB NoSQL connector uses **JSON**.

## ID Format

The document ID is composed of the shard key followed by the `id` field. The `id` field is always the last part of the ID. If `id` is itself part of the shard key, it is not duplicated.

For example, with a shard key of `/region`:

| `id`    | `region`    | Document ID          |
| ------- | ----------- | -------------------- |
| `"123"` | `"us-east"` | `["us-east", "123"]` |

With a shard key of `/id` (where `id` is the shard key):

| `id`    | Document ID |
| ------- | ----------- |
| `"123"` | `["123"]`   |

With a hierarchical shard key of `/region/tenant`:

| `id`    | `region`    | `tenant` | Document ID                  |
| ------- | ----------- | -------- | ---------------------------- |
| `"123"` | `"us-east"` | `"acme"` | `["us-east", "acme", "123"]` |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.adiom.io/reference/connectors/cosmos-db-nosql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
