|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Azure;
namespace Aspire.Hosting;
/// <summary>
/// A resource that represents an Azure Cosmos DB.
/// </summary>
public class AzureCosmosDBResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure) :
AzureProvisioningResource(name, configureInfrastructure),
IResourceWithConnectionString,
IResourceWithEndpoints
{
internal List<string> Databases { get; } = [];
internal EndpointReference EmulatorEndpoint => new(this, "emulator");
/// <summary>
/// Gets the "connectionString" reference from the secret outputs of the Azure Cosmos DB resource.
/// </summary>
public BicepSecretOutputReference ConnectionString => new("connectionString", this);
/// <summary>
/// Gets a value indicating whether the Azure Cosmos DB resource is running in the local emulator.
/// </summary>
public bool IsEmulator => this.IsContainer();
/// <summary>
/// Gets the connection string template for the manifest for the Azure Cosmos DB resource.
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
IsEmulator
? AzureCosmosDBEmulatorConnectionString.Create(EmulatorEndpoint)
: ReferenceExpression.Create($"{ConnectionString}");
}
|