Skip to main content

Azure Cosmos DB developer hub

Build with Azure Cosmos DB

Build apps and AI agents on a globally distributed database. SDKs, tools and samples, plus the community and training to go with them.

Give an AI agent a memory: store it, then recall it by meaning.

pip install azure-cosmos
# container has a vector index on /embedding
# embed() calls your embedding model
container.upsert_item({
"id": "m1",
"userId": "ava",
"text": "Prefers window seats",
"embedding": embed("Prefers window seats"),
})
hits = container.query_items(
query="SELECT TOP 3 c.text, VectorDistance(c.embedding, @q) AS score "
"FROM c ORDER BY VectorDistance(c.embedding, @q)",
parameters=[{"name": "@q", "value": embed("Where should Ava sit?")}],
partition_key="ava",
)
dotnet add package Microsoft.Azure.Cosmos
// container has a vector index on /embedding
// Embed() calls your embedding model
PartitionKey pk = new("ava");
await container.UpsertItemAsync(
new Memory("m1", "ava", "Prefers window seats", Embed("Prefers window seats")), pk);
QueryDefinition query = new QueryDefinition(
"SELECT TOP 3 c.text, VectorDistance(c.embedding, @q) AS score " +
"FROM c ORDER BY VectorDistance(c.embedding, @q)")
.WithParameter("@q", Embed("Where should Ava sit?"));
using FeedIterator<MemoryHit> hits = container.GetItemQueryIterator<MemoryHit>(
query, requestOptions: new QueryRequestOptions { PartitionKey = pk });
record Memory(string id, string userId, string text, float[] embedding);
record MemoryHit(string text, double score);
com.azure:azure-cosmos (Maven / Gradle)
// container has a vector index on /embedding
// embed() calls your embedding model
container.upsertItem(
new Memory("m1", "ava", "Prefers window seats", embed("Prefers window seats")));
SqlQuerySpec query = new SqlQuerySpec(
"SELECT TOP 3 c.text, VectorDistance(c.embedding, @q) AS score "
+ "FROM c ORDER BY VectorDistance(c.embedding, @q)",
new SqlParameter("@q", embed("Where should Ava sit?")));
CosmosPagedIterable<MemoryHit> hits = container.queryItems(
query,
new CosmosQueryRequestOptions().setPartitionKey(new PartitionKey("ava")),
MemoryHit.class);
npm install @azure/cosmos
// container has a vector index on /embedding
// embed() calls your embedding model
await container.items.upsert({
id: "m1",
userId: "ava",
text: "Prefers window seats",
embedding: await embed("Prefers window seats"),
});
const { resources: hits } = await container.items
.query(
{
query:
"SELECT TOP 3 c.text, VectorDistance(c.embedding, @q) AS score " +
"FROM c ORDER BY VectorDistance(c.embedding, @q)",
parameters: [{ name: "@q", value: await embed("Where should Ava sit?") }],
},
{ partitionKey: "ava" },
)
.fetchAll();
go get github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos
// container has a vector index on /embedding
// embed() calls your embedding model
// error handling omitted for brevity
pk := azcosmos.NewPartitionKeyString("ava")
body, _ := json.Marshal(map[string]any{
"id": "m1", "userId": "ava", "text": "Prefers window seats",
"embedding": embed("Prefers window seats"),
})
_, _ = container.UpsertItem(ctx, pk, body, nil)
pager := container.NewQueryItemsPager(
"SELECT TOP 3 c.text, VectorDistance(c.embedding, @q) AS score "+
"FROM c ORDER BY VectorDistance(c.embedding, @q)",
pk,
&azcosmos.QueryOptions{QueryParameters: []azcosmos.QueryParameter{
{Name: "@q", Value: embed("Where should Ava sit?")}, // []float64
}},
)
cargo add azure_data_cosmos futures
// container has a vector index on /embedding
// embed() calls your embedding model
let memory = Memory {
id: "m1".into(),
user_id: "ava".into(),
text: "Prefers window seats".into(),
embedding: embed("Prefers window seats"),
};
container.upsert_item("ava", "m1", memory, None).await?;
let query = Query::from(
"SELECT TOP 3 c.text, VectorDistance(c.embedding, @q) AS score \
FROM c ORDER BY VectorDistance(c.embedding, @q)",
)
.with_parameter("@q", embed("Where should Ava sit?"))?;
let mut hits = container
.query_items::<MemoryHit>(query, FeedScope::partition("ava"), None)
.await?;
while let Some(hit) = hits.try_next().await? {
println!("{} ({})", hit.text, hit.score);
}

Develop

Pick your language to see its quickstart, SDK guide and API reference.

Developer guide

Get started with Python

Install the SDK, connect to your account and run your first query.

Queries & change feed

Read your data back and react to every change.

Vector search & AI

Build retrieval and agent memory on your operational data.

Performance & cost

Understand request units and tune for throughput.

Consistency & global distribution

Trade latency, availability and consistency on purpose.

What will you create?

Start with a real scenario. Find the code, learn the pattern, and make it your own.

Looking for working code? Start from a ready-made sample.Browse the sample gallery (opens in new tab)

Learn

From your first query to a credential you can show: watch it, read it, build with it, get certified.

New to Azure Cosmos DB? Start small. Run your first NoSQL queries.Try the introductory module on AI Skills Navigator (opens in new tab)

Get certified

DP-420AI-focused / Updated October 2026

Build confidence. Prove your skills.

Azure Cosmos DB AI Developer Associate

Design, build, and optimize scalable AI applications with Azure Cosmos DB. Bring your database fundamentals together with RAG, agent memory, and conversation state.

Explore the certification (opens in new tab)

Microsoft Certified: Azure Cosmos DB AI Developer Associate.

Take DP-420 for less

Microsoft Ignite / In person

November 17-20, 2026 / San Francisco

Ignite is your launchpad.

Meet the developer community, explore Azure Cosmos DB sessions, and take DP-420 onsite at no charge if you're a registered in-person attendee.

Testing: November 16-20. One Microsoft or one GitHub exam per eligible attendee. Registration, available seats, and official terms apply.

Explore onsite certification (opens in new tab)

Data Days: AI @ Work / Online

50% exam discount request opportunity

Keep the momentum going, wherever you are.

DP-420 is included in the Data Days certification offer. Join Fabric Community, watch two Data Days sessions, then submit a discount request.

November 2-December 15. Request by December 10, 2026, while supplies last. Eligibility and offer terms apply; issuance is not guaranteed. Offer terms (opens in new tab)

Explore Data Days (opens in new tab)

From the blog

Read the Azure Cosmos DB blog (opens in new tab)

Tools

Everything around the SDK: write and debug in your editor, let AI assistants work with your data, and plan and migrate your workload.

Build & debug

Write, run and inspect your data from the editor, the browser or your laptop.

AI-assisted development

Let coding assistants and agents work with Azure Cosmos DB, with the right guardrails.

Plan & migrate

Size your workload, then move your data in.

Community

Ask a question. Share a build. Join a conversation. Choose the community that works for you.

Cosmonauts

Meet the people behind the possibility. Get inspired by the people who build, teach, and share, then find your own path from learner to community leader.

From learner to community leader

Plot your path toward Cosmonaut recognition and Microsoft MVP.

Start by making a meaningful contribution. Grow expertise, help others, and build a body of work you're proud to share.

Understand the Microsoft MVP award (opens in new tab)
  1. Build real expertise. Create with Azure Cosmos DB. DP-420 can validate your skills; it is not a stated requirement for either recognition.
  2. Contribute consistently. Share useful projects, explain what you learned, answer questions, speak, and mentor.
  3. Connect with the Azure Cosmos DB community. Participate and share your work. Cosmonauts are nominated, so visible, consistent contributions are how you get noticed.
  4. Explore Microsoft MVP nomination. Document impactful, verifiable contributions from the last 12 months. A current MVP or Microsoft employee must nominate you before the application and review.

Cosmonaut recognition and Microsoft MVP are separate. Passing DP-420 or participating does not guarantee either. Cosmonauts are nominated; there is no public Cosmonaut application process.

Events & updates

Get together with the community and the product team, and keep up with what's new.

Updates

The latest Azure Cosmos DB announcements from Azure Updates.

See all Azure Cosmos DB updates (opens in new tab)