# AzureCosmosDBResource

- Kind: `class`
- Package: [Aspire.Hosting.Azure.CosmosDB](/reference/api/csharp/aspire.hosting.azure.cosmosdb.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs)
- Inherits: `AzureProvisioningResource`
- Implements: `IExpressionValue`, `IManifestExpressionProvider`, `IResource`, `IResourceWithConnectionString`, `IResourceWithEndpoints`, `IValueProvider`, `IValueWithReferences`, `IAzureNspAssociationTarget`, `IAzurePrivateEndpointTarget`, `IResourceWithAzureFunctionsConfig`

A resource that represents an Azure Cosmos DB.

## Definition

```csharp
namespace Aspire.Hosting;

public class AzureCosmosDBResource
    : Aspire.Hosting.Azure.AzureProvisioningResource,
      Aspire.Hosting.ApplicationModel.IExpressionValue,
      Aspire.Hosting.ApplicationModel.IManifestExpressionProvider,
      Aspire.Hosting.ApplicationModel.IResource,
      Aspire.Hosting.ApplicationModel.IResourceWithConnectionString,
      Aspire.Hosting.ApplicationModel.IResourceWithEndpoints,
      Aspire.Hosting.ApplicationModel.IValueProvider,
      Aspire.Hosting.ApplicationModel.IValueWithReferences,
      Aspire.Hosting.Azure.IAzureNspAssociationTarget,
      Aspire.Hosting.Azure.IAzurePrivateEndpointTarget,
      Aspire.Hosting.Azure.IResourceWithAzureFunctionsConfig
{
    // ...
}
```

## Constructors

- [AzureCosmosDBResource(string, Action<AzureResourceInfrastructure>)](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/constructors.md#constructor-string-action-azureresourceinfrastructure) -- A resource that represents an Azure Cosmos DB.

## Properties

- [AccountKey](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#accountkey) : `ReferenceExpression?` `get` -- Gets the account key expression for the Cosmos DB account.
- [ConnectionString](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#connectionstring) : `BicepSecretOutputReference` `get` `obsolete` -- Gets the "connectionString" reference from the secret outputs of the Azure Cosmos DB resource.
- [ConnectionStringExpression](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#connectionstringexpression) : `ReferenceExpression` `get` -- Gets the connection string template for the manifest for the Azure Cosmos DB resource.
- [ConnectionStringOutput](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#connectionstringoutput) : `BicepOutputReference` `get` -- Gets the "connectionString" output reference from the bicep template for the Azure Cosmos DB resource. This is used when Entra ID authentication is used. The connection string is an output of the bicep template.
- [Id](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#id) : `BicepOutputReference` `get` -- Gets the "id" output reference for the resource.
- [IsEmulator](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#isemulator) : `bool` `get` -- Gets a value indicating whether the Azure Cosmos DB resource is running in the local emulator.
- [NameOutputReference](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#nameoutputreference) : `BicepOutputReference` `get` -- Gets the "name" output reference for the resource.
- [UriExpression](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#uriexpression) : `ReferenceExpression` `get` -- Gets the account endpoint URI expression for the Cosmos DB account.
- [UseAccessKeyAuthentication](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/properties.md#useaccesskeyauthentication) : `bool` `get` -- Gets a value indicating whether the resource uses access key authentication.

## Methods

- [AddAsExistingResource(AzureResourceInfrastructure)](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/methods.md#addasexistingresource-azureresourceinfrastructure) : `ProvisionableResource`
- [AddRoleAssignments(IAddRoleAssignmentsContext)](/reference/api/csharp/aspire.hosting.azure.cosmosdb/azurecosmosdbresource/methods.md#addroleassignments-iaddroleassignmentscontext)
