diff --git a/docs/azureai/azureai-openai-integration.md b/docs/azureai/azureai-openai-integration.md index a34f698ece..1d736b7141 100644 --- a/docs/azureai/azureai-openai-integration.md +++ b/docs/azureai/azureai-openai-integration.md @@ -125,34 +125,8 @@ builder.AddProject() For more information on treating Azure OpenAI resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -Alternatively, instead of representing an Azure OpenAI resource, you can add a connection string to the app host. Which is a weakly-typed approach that's based solely on a `string` value. To add a connection to an existing Azure OpenAI service, call the method: - -```csharp -var builder = DistributedApplication.CreateBuilder(args); - -var openai = builder.ExecutionContext.IsPublishMode - ? builder.AddAzureOpenAI("openai") - : builder.AddConnectionString("openai"); - -builder.AddProject() - .WithReference(openai); - -// After adding all resources, run the app... -``` - -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under User Secrets, under the `ConnectionStrings` section: - -```json -{ - "ConnectionStrings": { - "openai": "https://{account_name}.openai.azure.com/" - } -} -``` - -For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). +> [!NOTE] +> Alternatively, instead of representing an Azure OpenAI resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ## Client integration diff --git a/docs/azureai/azureai-search-document-integration.md b/docs/azureai/azureai-search-document-integration.md index bc19486018..e85dc856c4 100644 --- a/docs/azureai/azureai-search-document-integration.md +++ b/docs/azureai/azureai-search-document-integration.md @@ -103,34 +103,8 @@ builder.AddProject() For more information on treating Azure AI Search resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -Alternatively, instead of representing an Azure AI Search resource, you can add a connection string to the app host. Which is a weakly-typed approach that's based solely on a `string` value. To add a connection to an existing Azure AI Search service, call the method: - -```csharp -var builder = DistributedApplication.CreateBuilder(args); - -var search = builder.ExecutionContext.IsPublishMode - ? builder.AddAzureSearch("search") - : builder.AddConnectionString("search"); - -builder.AddProject() - .WithReference(search); - -// After adding all resources, run the app... -``` - -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under User Secrets, under the `ConnectionStrings` section: - -```json -{ - "ConnectionStrings": { - "search": "https://{account_name}.search.azure.com/" - } -} -``` - -For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). +> [!NOTE] +> Alternatively, instead of representing an Azure AI Search resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Hosting integration health checks diff --git a/docs/caching/includes/azure-redis-app-host.md b/docs/caching/includes/azure-redis-app-host.md index 980293ba97..939f2a250a 100644 --- a/docs/caching/includes/azure-redis-app-host.md +++ b/docs/caching/includes/azure-redis-app-host.md @@ -75,32 +75,27 @@ There are many more configuration options available to customize the Azure Cache ### Connect to an existing Azure Cache for Redis -You might have an existing Azure Cache for Redis that you want to connect to. Instead of representing a new Azure Cache for Redis resource, you can add a connection string to the app host. To add a connection to an existing Azure Cache for Redis, call the method: +You might have an existing Azure Cache for Redis resource that you want to connect to. You can chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var cache = builder.AddConnectionString("azure-redis"); +var existingRedisName = builder.AddParameter("existingRedisName"); +var existingRedisResourceGroup = builder.AddParameter("existingRedisResourceGroup"); -builder.AddProject("web") +var cache = builder.AddAzureRedis("azcache") + .AsExisting(existingRedisName, existingRedisResourceGroup); + +builder.AddProject() .WithReference(cache); // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "azure-redis": ".redis.cache.windows.net:6380,ssl=true,abortConnect=False" - } -} -``` +For more information on treating Azure Cache for Redis resources as existing resources, see [Use existing Azure resources](../../azure/integrations-overview.md#use-existing-azure-resources). -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"azure-redis"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure Cache for Redis resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Run Azure Cache for Redis resource as a container diff --git a/docs/database/includes/azure-sql-hosting.md b/docs/database/includes/azure-sql-hosting.md index fb55df3e07..283fbdee90 100644 --- a/docs/database/includes/azure-sql-hosting.md +++ b/docs/database/includes/azure-sql-hosting.md @@ -45,32 +45,28 @@ The preceding call to `AddAzureSqlServer` configures the Azure SQL server resour ### Connect to an existing Azure SQL server -You might have an existing Azure SQL database that you want to connect to. Instead of representing a new Azure SQL server resource, you can add a connection string to the app host. To add a connection to an existing Azure SQL server, call the method: +You might have an existing Azure SQL Database service that you want to connect to. You can chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var azureSql = builder.AddConnectionString("database"); +var existingSqlServerName = builder.AddParameter("existingSqlServerName"); +var existingSqlServerResourceGroup = builder.AddParameter("existingSqlServerResourceGroup"); -builder.AddProject("web") - .WithReference(azureSql); +var sqlserver = builder.AddAzureSqlServer("sqlserver") + .AsExisting(existingSqlServerName, existingSqlServerResourceGroup) + .AddDatabase("database"); + +builder.AddProject() + .WithReference(sqlserver); // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "database": "Server=tcp:.database.windows.net,1433;Initial Catalog=;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;User ID=;" - } -} -``` +For more information on treating Azure SQL Database resources as existing resources, see [Use existing Azure resources](../../azure/integrations-overview.md#use-existing-azure-resources). -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"database"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure SQL Database resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Run Azure SQL server resource as a container diff --git a/docs/database/includes/cosmos-app-host.md b/docs/database/includes/cosmos-app-host.md index 73ae9dd568..12cadff99c 100644 --- a/docs/database/includes/cosmos-app-host.md +++ b/docs/database/includes/cosmos-app-host.md @@ -76,12 +76,16 @@ There are many more configuration options available to customize the Azure Cosmo ### Connect to an existing Azure Cosmos DB account -You might have an existing Azure Cosmos DB account that you want to connect to. Instead of representing a new Azure Cosmos DB resource, you can add a connection string to the app host. To add a connection to an existing Azure Cosmos DB account, call the method: +You might have an existing Azure Cosmos DB account that you want to connect to. You can chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var cosmos = builder.AddConnectionString("cosmos-db"); +var existingCosmosName = builder.AddParameter("existingCosmosName"); +var existingCosmosResourceGroup = builder.AddParameter("existingCosmosResourceGroup"); + +var cosmos = builder.AddAzureCosmosDB("cosmos-db") + .AsExisting(existingCosmosName, existingCosmosResourceGroup); builder.AddProject("web") .WithReference(cosmos); @@ -89,19 +93,10 @@ builder.AddProject("web") // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "cosmos-db": "AccountEndpoint=https://{account_name}.documents.azure.com:443/;AccountKey={account_key};" - } -} -``` +For more information on treating Azure Cosmos DB resources as existing resources, see [Use existing Azure resources](../../azure/integrations-overview.md#use-existing-azure-resources). -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"cosmos-db"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure Cosmos DB resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Add Azure Cosmos DB database and container resources diff --git a/docs/database/includes/postgresql-flexible-server.md b/docs/database/includes/postgresql-flexible-server.md index a54a22c14f..58bb9033fd 100644 --- a/docs/database/includes/postgresql-flexible-server.md +++ b/docs/database/includes/postgresql-flexible-server.md @@ -88,32 +88,27 @@ There are many more configuration options available to customize the PostgreSQL ### Connect to an existing Azure PostgreSQL flexible server -You might have an existing Azure PostgreSQL flexible server that you want to connect to. Instead of representing a new Azure PostgreSQL flexible server resource, you can add a connection string to the app host. To add a connection to an existing Azure PostgreSQL flexible server, call the method: +You might have an existing Azure PostgreSQL flexible server that you want to connect to. Chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var postgres = builder.AddConnectionString("postgres"); +var existingPostgresName = builder.AddParameter("existingPostgresName"); +var existingPostgresResourceGroup = builder.AddParameter("existingPostgresResourceGroup"); -builder.AddProject("web") +var postgres = builder.AddAzurePostgresFlexibleServer("postgres") + .AsExisting(existingPostgresName, existingPostgresResourceGroup); + +builder.AddProject() .WithReference(postgres); // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "postgres": "Server=.postgres.database.azure.com;Database=;Port=5432;Ssl Mode=Require;User Id=;" - } -} -``` +For more information on treating Azure PostgreSQL flexible server resources as existing resources, see [Use existing Azure resources](../../azure/integrations-overview.md#use-existing-azure-resources). -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"postgres"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure PostgreSQL flexible server resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Run Azure PostgreSQL resource as a container diff --git a/docs/messaging/azure-event-hubs-integration.md b/docs/messaging/azure-event-hubs-integration.md index 6265c24862..0de97b2531 100644 --- a/docs/messaging/azure-event-hubs-integration.md +++ b/docs/messaging/azure-event-hubs-integration.md @@ -91,32 +91,27 @@ There are many more configuration options available to customize the Event Hubs ### Connect to an existing Azure Event Hubs namespace -You might have an existing Azure Event Hubs namespace that you want to connect to. Instead of representing a new Azure Event Hubs resource, you can add a connection string to the app host. To add a connection to an existing Azure Event Hubs namespace, call the method: +You might have an existing Azure Event Hubs service that you want to connect to. You can chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var eventHubs = builder.AddConnectionString("event-hubs"); +var existingEventHubsName = builder.AddParameter("existingEventHubsName"); +var existingEventHubsResourceGroup = builder.AddParameter("existingEventHubsResourceGroup"); -builder.AddProject("web") +var eventHubs = builder.AddAzureEventHubs("event-hubs") + .AsExisting(existingEventHubsName, existingEventHubsResourceGroup); + +builder.AddProject() .WithReference(eventHubs); // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "event-hubs": "{your_namespace}.servicebus.windows.net" - } -} -``` +For more information on treating Azure Event Hubs resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"event-hubs"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure Event Hubs resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Add Event Hub consumer group diff --git a/docs/messaging/azure-service-bus-integration.md b/docs/messaging/azure-service-bus-integration.md index 19e5c4ae1e..7545c9eb91 100644 --- a/docs/messaging/azure-service-bus-integration.md +++ b/docs/messaging/azure-service-bus-integration.md @@ -87,12 +87,16 @@ There are many more configuration options available to customize the Azure Servi ### Connect to an existing Azure Service Bus namespace -You might have an existing Azure Service Bus namespace that you want to connect to. Instead of representing a new Azure Service Bus resource, you can add a connection string to the app host. To add a connection to an existing Azure Service Bus namespace, call the method: +You might have an existing Azure Service Bus namespace that you want to connect to. Chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var serviceBus = builder.AddConnectionString("messaging"); +var existingServiceBusName = builder.AddParameter("existingServiceBusName"); +var existingServiceBusResourceGroup = builder.AddParameter("existingServiceBusResourceGroup"); + +var serviceBus = builder.AddAzureServiceBus("messaging") + .AsExisting(existingServiceBusName, existingServiceBusResourceGroup); builder.AddProject("web") .WithReference(serviceBus); @@ -100,19 +104,10 @@ builder.AddProject("web") // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "messaging": "Endpoint=sb://{namespace}.servicebus.windows.net/;SharedAccessKeyName={key_name};SharedAccessKey={key_value};" - } -} -``` +For more information on treating Azure Service Bus resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"messaging"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure Service Bus resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Add Azure Service Bus queue diff --git a/docs/messaging/azure-web-pubsub-integration.md b/docs/messaging/azure-web-pubsub-integration.md index 6864e9366d..bf29949ba2 100644 --- a/docs/messaging/azure-web-pubsub-integration.md +++ b/docs/messaging/azure-web-pubsub-integration.md @@ -145,34 +145,8 @@ builder.AddProject() For more information on treating Azure Web PubSub resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -Alternatively, instead of representing an Azure Web PubSub resource, you can add a connection string to the app host. Which is a weakly-typed approach that's based solely on a `string` value. To add a connection to an existing Azure Web PubSub service, call the method: - -```csharp -var builder = DistributedApplication.CreateBuilder(args); - -var webPubSub = builder.ExecutionContext.IsPublishMode - ? builder.AddAzureWebPubSub("web-pubsub") - : builder.AddConnectionString("web-pubsub"); - -builder.AddProject() - .WithReference(webPubSub); - -// After adding all resources, run the app... -``` - -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under User Secrets, under the `ConnectionStrings` section: - -```json -{ - "ConnectionStrings": { - "web-pubsub": "https://{account_name}.webpubsub.azure.com" - } -} -``` - -For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). +> [!NOTE] +> Alternatively, instead of representing an Azure AI Search resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ## Client integration diff --git a/docs/real-time/azure-signalr-scenario.md b/docs/real-time/azure-signalr-scenario.md index 144c867ae9..188cc7e5ae 100644 --- a/docs/real-time/azure-signalr-scenario.md +++ b/docs/real-time/azure-signalr-scenario.md @@ -114,32 +114,8 @@ builder.AddProject() For more information on treating Azure SignalR resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -Alternatively, instead of representing an Azure SignalR resource, you can add a connection string to the app host. Which is a weakly-typed approach that's based solely on a `string` value. To add a connection to an existing Azure SignalR Service, call the method: - -```csharp -var builder = DistributedApplication.CreateBuilder(args); - -var signalr = builder.ExecutionContext.IsPublishMode - ? builder.AddAzureSignalR("signalr") - : builder.AddConnectionString("signalr"); - -builder.AddProject("apiService") - .WithReference(signalr); -``` - -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section: - -```json -{ - "ConnectionStrings": { - "signalr": "Endpoint=https://your-signalr-instance.service.signalr.net;AccessKey=your-access-key;Version=1.0;" - } -} -``` - -For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). +> [!NOTE] +> Alternatively, instead of representing an Azure SignalR Service resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Add an Azure SignalR Service emulator resource diff --git a/docs/security/azure-security-key-vault-integration.md b/docs/security/azure-security-key-vault-integration.md index 2cfd98af69..f49187b649 100644 --- a/docs/security/azure-security-key-vault-integration.md +++ b/docs/security/azure-security-key-vault-integration.md @@ -87,32 +87,27 @@ There are many more configuration options available to customize the Key Vault r ### Connect to an existing Azure Key Vault instance -You might have an existing Azure Key Vault instance that you want to connect to. Instead of representing a new Azure Key Vault resource, you can add a connection string to the app host. To add a connection to an existing Azure Key Vault resource, call the method: +You might have an existing Azure AI Key Vault instance that you want to connect to. You can chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var keyVault = builder.AddConnectionString("key-vault"); +var existingKeyVaultName = builder.AddParameter("existingKeyVaultName"); +var existingKeyVaultResourceGroup = builder.AddParameter("existingKeyVaultResourceGroup"); -builder.AddProject("web") - .WithReference(keyVault); +var keyvault = builder.AddAzureKeyVault("ke-yvault") + .AsExisting(existingKeyVaultName, existingKeyVaultResourceGroup); + +builder.AddProject() + .WithReference(keyvault); // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)] +For more information on treating Azure Key Vault resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources). -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: - -```json -{ - "ConnectionStrings": { - "key-vault": "https://{account_name}.vault.azure.net/" - } -} -``` - -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"key-vault"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure Key Vault resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ## Client integration diff --git a/docs/storage/includes/storage-app-host.md b/docs/storage/includes/storage-app-host.md index a66e374331..422103205a 100644 --- a/docs/storage/includes/storage-app-host.md +++ b/docs/storage/includes/storage-app-host.md @@ -102,32 +102,28 @@ There are many more configuration options available to customize the Azure Stora ### Connect to an existing Azure Storage account -You might have an existing Azure Storage account that you want to connect to. Instead of representing a new Azure Storage resource, you can add a connection string to the app host. To add a connection to an existing Azure Storage account, call the method: +You might have an existing Azure Storage account that you want to connect to. You can chain a call to annotate that your is an existing resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); -var blobs = builder.AddConnectionString("blobs"); +var existingStorageName = builder.AddParameter("existingStorageName"); +var existingStorageResourceGroup = builder.AddParameter("existingStorageResourceGroup"); -builder.AddProject("web") - .WithReference(blobs); +var storageaccount = builder.AddAzureStorage("storage") + .AsExisting(existingStorageName, existingStorageResourceGroup) + .AddBlobs("blobs"); + +builder.AddProject() + .WithReference(storageaccount); // After adding all resources, run the app... ``` -[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)] - -The connection string is configured in the app host's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The app host injects this connection string as an environment variable into all dependent resources, for example: +For more information on treating Azure Storage resources as existing resources, see [Use existing Azure resources](../../azure/integrations-overview.md#use-existing-azure-resources). -```json -{ - "ConnectionStrings": { - "blobs": "https://{account_name}.blob.core.windows.net/" - } -} -``` - -The dependent resource can access the injected connection string by calling the method, and passing the connection name as the parameter, in this case `"blobs"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. +> [!NOTE] +> Alternatively, instead of representing an Azure Storage account resource, you can add a connection string to the app host. This approach is weakly-typed, and doesn't work with role assignments or infrastructure customizations. For more information, see [Add existing Azure resources with connection strings](../../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings). ### Add Azure Storage emulator resource