﻿---
title: Azure Cosmos DB
description: Instrumentation can be enabled for Azure Cosmos DB by referencing Elastic.Apm.Azure.CosmosDb package and subscribing to diagnostic events. Diagnostic...
url: https://www.elastic.co/elastic/docs-builder/docs/2649/reference/apm/agents/dotnet/setup-azure-cosmosdb
products:
  - APM .NET Agent
  - APM Agent
applies_to:
  - Serverless Observability projects: Generally available
  - Elastic Stack: Generally available
  - Application Performance Monitoring Agent for .NET: Generally available
---

# Azure Cosmos DB
## Quick start

Instrumentation can be enabled for Azure Cosmos DB by referencing [`Elastic.Apm.Azure.CosmosDb`](https://www.nuget.org/packages/Elastic.Apm.Azure.CosmosDb) package and subscribing to diagnostic events.
```csharp
Agent.Subscribe(new AzureCosmosDbDiagnosticsSubscriber());
```

Diagnostic events from `Microsoft.Azure.Cosmos`, `Microsoft.Azure.DocumentDb`, and `Microsoft.Azure.DocumentDb.Core` are captured as DB spans.