Skip to content

Commit e68b830

Browse files
Merge pull request #3825 from dotnet/main
✅ Merge `main` into `live`
2 parents f0a608b + 18c266a commit e68b830

22 files changed

+277
-257
lines changed

docs/azureai/azureai-openai-integration.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -125,34 +125,8 @@ builder.AddProject<Projects.ExampleProject>()
125125

126126
For more information on treating Azure OpenAI resources as existing resources, see [Use existing Azure resources](../azure/integrations-overview.md#use-existing-azure-resources).
127127

128-
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 <xref:Aspire.Hosting.ParameterResourceBuilderExtensions.AddConnectionString%2A> method:
129-
130-
```csharp
131-
var builder = DistributedApplication.CreateBuilder(args);
132-
133-
var openai = builder.ExecutionContext.IsPublishMode
134-
? builder.AddAzureOpenAI("openai")
135-
: builder.AddConnectionString("openai");
136-
137-
builder.AddProject<Projects.ExampleProject>()
138-
.WithReference(openai);
139-
140-
// After adding all resources, run the app...
141-
```
142-
143-
[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)]
144-
145-
The connection string is configured in the app host's configuration, typically under User Secrets, under the `ConnectionStrings` section:
146-
147-
```json
148-
{
149-
"ConnectionStrings": {
150-
"openai": "https://{account_name}.openai.azure.com/"
151-
}
152-
}
153-
```
154-
155-
For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings).
128+
> [!NOTE]
129+
> 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).
156130
157131
## Client integration
158132

docs/azureai/azureai-search-document-integration.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,8 @@ builder.AddProject<Projects.ExampleProject>()
103103

104104
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).
105105

106-
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 <xref:Aspire.Hosting.ParameterResourceBuilderExtensions.AddConnectionString%2A> method:
107-
108-
```csharp
109-
var builder = DistributedApplication.CreateBuilder(args);
110-
111-
var search = builder.ExecutionContext.IsPublishMode
112-
? builder.AddAzureSearch("search")
113-
: builder.AddConnectionString("search");
114-
115-
builder.AddProject<Projects.ExampleProject>()
116-
.WithReference(search);
117-
118-
// After adding all resources, run the app...
119-
```
120-
121-
[!INCLUDE [connection-strings-alert](../includes/connection-strings-alert.md)]
122-
123-
The connection string is configured in the app host's configuration, typically under User Secrets, under the `ConnectionStrings` section:
124-
125-
```json
126-
{
127-
"ConnectionStrings": {
128-
"search": "https://{account_name}.search.azure.com/"
129-
}
130-
}
131-
```
132-
133-
For more information, see [Add existing Azure resources with connection strings](../azure/integrations-overview.md#add-existing-azure-resources-with-connection-strings).
106+
> [!NOTE]
107+
> 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).
134108
135109
### Hosting integration health checks
136110

docs/caching/includes/azure-redis-app-host.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,27 @@ There are many more configuration options available to customize the Azure Cache
7575

7676
### Connect to an existing Azure Cache for Redis
7777

78-
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 <xref:Aspire.Hosting.ParameterResourceBuilderExtensions.AddConnectionString*> method:
78+
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 <xref:Aspire.Hosting.Azure.AzureRedisCacheResource> is an existing resource:
7979

8080
```csharp
8181
var builder = DistributedApplication.CreateBuilder(args);
8282

83-
var cache = builder.AddConnectionString("azure-redis");
83+
var existingRedisName = builder.AddParameter("existingRedisName");
84+
var existingRedisResourceGroup = builder.AddParameter("existingRedisResourceGroup");
8485

85-
builder.AddProject<Projects.WebApplication>("web")
86+
var cache = builder.AddAzureRedis("azcache")
87+
.AsExisting(existingRedisName, existingRedisResourceGroup);
88+
89+
builder.AddProject<Projects.ExampleProject>()
8690
.WithReference(cache);
8791

8892
// After adding all resources, run the app...
8993
```
9094

91-
[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)]
92-
93-
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:
94-
95-
```json
96-
{
97-
"ConnectionStrings": {
98-
"azure-redis": "<your-redis-name>.redis.cache.windows.net:6380,ssl=true,abortConnect=False"
99-
}
100-
}
101-
```
95+
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).
10296

103-
The dependent resource can access the injected connection string by calling the <xref:Microsoft.Extensions.Configuration.ConfigurationExtensions.GetConnectionString*> method, and passing the connection name as the parameter, in this case `"azure-redis"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`.
97+
> [!NOTE]
98+
> 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).
10499
105100
### Run Azure Cache for Redis resource as a container
106101

docs/database/includes/azure-sql-hosting.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,28 @@ The preceding call to `AddAzureSqlServer` configures the Azure SQL server resour
4545
4646
### Connect to an existing Azure SQL server
4747

48-
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 <xref:Aspire.Hosting.ParameterResourceBuilderExtensions.AddConnectionString*> method:
48+
You might have an existing Azure SQL Database service that you want to connect to. You can chain a call to annotate that your <xref:Aspire.Hosting.Azure.AzureSqlServerResource> is an existing resource:
4949

5050
```csharp
5151
var builder = DistributedApplication.CreateBuilder(args);
5252

53-
var azureSql = builder.AddConnectionString("database");
53+
var existingSqlServerName = builder.AddParameter("existingSqlServerName");
54+
var existingSqlServerResourceGroup = builder.AddParameter("existingSqlServerResourceGroup");
5455

55-
builder.AddProject<Projects.WebApplication>("web")
56-
.WithReference(azureSql);
56+
var sqlserver = builder.AddAzureSqlServer("sqlserver")
57+
.AsExisting(existingSqlServerName, existingSqlServerResourceGroup)
58+
.AddDatabase("database");
59+
60+
builder.AddProject<Projects.ExampleProject>()
61+
.WithReference(sqlserver);
5762

5863
// After adding all resources, run the app...
5964
```
6065

61-
[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)]
62-
63-
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:
64-
65-
```json
66-
{
67-
"ConnectionStrings": {
68-
"database": "Server=tcp:<Azure-SQL-server-name>.database.windows.net,1433;Initial Catalog=<database-name>;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;User ID=<username>;"
69-
}
70-
}
71-
```
66+
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).
7267

73-
The dependent resource can access the injected connection string by calling the <xref:Microsoft.Extensions.Configuration.ConfigurationExtensions.GetConnectionString*> method, and passing the connection name as the parameter, in this case `"database"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`.
68+
> [!NOTE]
69+
> 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).
7470
7571
### Run Azure SQL server resource as a container
7672

docs/database/includes/cosmos-app-host.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,27 @@ There are many more configuration options available to customize the Azure Cosmo
7676

7777
### Connect to an existing Azure Cosmos DB account
7878

79-
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 <xref:Aspire.Hosting.ParameterResourceBuilderExtensions.AddConnectionString*> method:
79+
You might have an existing Azure Cosmos DB account that you want to connect to. You can chain a call to annotate that your <xref:Aspire.Hosting.AzureCosmosDBResource> is an existing resource:
8080

8181
```csharp
8282
var builder = DistributedApplication.CreateBuilder(args);
8383

84-
var cosmos = builder.AddConnectionString("cosmos-db");
84+
var existingCosmosName = builder.AddParameter("existingCosmosName");
85+
var existingCosmosResourceGroup = builder.AddParameter("existingCosmosResourceGroup");
86+
87+
var cosmos = builder.AddAzureCosmosDB("cosmos-db")
88+
.AsExisting(existingCosmosName, existingCosmosResourceGroup);
8589

8690
builder.AddProject<Projects.WebApplication>("web")
8791
.WithReference(cosmos);
8892

8993
// After adding all resources, run the app...
9094
```
9195

92-
[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)]
93-
94-
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:
95-
96-
```json
97-
{
98-
"ConnectionStrings": {
99-
"cosmos-db": "AccountEndpoint=https://{account_name}.documents.azure.com:443/;AccountKey={account_key};"
100-
}
101-
}
102-
```
96+
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).
10397

104-
The dependent resource can access the injected connection string by calling the <xref:Microsoft.Extensions.Configuration.ConfigurationExtensions.GetConnectionString*> method, and passing the connection name as the parameter, in this case `"cosmos-db"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`.
98+
> [!NOTE]
99+
> 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).
105100
106101
### Add Azure Cosmos DB database and container resources
107102

docs/database/includes/postgresql-flexible-server.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,27 @@ There are many more configuration options available to customize the PostgreSQL
8888

8989
### Connect to an existing Azure PostgreSQL flexible server
9090

91-
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 <xref:Aspire.Hosting.ParameterResourceBuilderExtensions.AddConnectionString*> method:
91+
You might have an existing Azure PostgreSQL flexible server that you want to connect to. Chain a call to annotate that your <xref:Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource> is an existing resource:
9292

9393
```csharp
9494
var builder = DistributedApplication.CreateBuilder(args);
9595

96-
var postgres = builder.AddConnectionString("postgres");
96+
var existingPostgresName = builder.AddParameter("existingPostgresName");
97+
var existingPostgresResourceGroup = builder.AddParameter("existingPostgresResourceGroup");
9798

98-
builder.AddProject<Projects.WebApplication>("web")
99+
var postgres = builder.AddAzurePostgresFlexibleServer("postgres")
100+
.AsExisting(existingPostgresName, existingPostgresResourceGroup);
101+
102+
builder.AddProject<Projects.ExampleProject>()
99103
.WithReference(postgres);
100104

101105
// After adding all resources, run the app...
102106
```
103107

104-
[!INCLUDE [connection-strings-alert](../../includes/connection-strings-alert.md)]
105-
106-
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:
107-
108-
```json
109-
{
110-
"ConnectionStrings": {
111-
"postgres": "Server=<PostgreSQL-server-name>.postgres.database.azure.com;Database=<database-name>;Port=5432;Ssl Mode=Require;User Id=<username>;"
112-
}
113-
}
114-
```
108+
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).
115109

116-
The dependent resource can access the injected connection string by calling the <xref:Microsoft.Extensions.Configuration.ConfigurationExtensions.GetConnectionString*> method, and passing the connection name as the parameter, in this case `"postgres"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`.
110+
> [!NOTE]
111+
> 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).
117112
118113
### Run Azure PostgreSQL resource as a container
119114

0 commit comments

Comments
 (0)