Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE
Use the `GetValue()` method to obtain these environment variables in consuming projects:

```csharp title="C# - Obtain configuration properties"
string connectionString = builder.Configuration.GetValue<string>("ConnectionStrings__mysqldb");
string host = builder.Configuration.GetValue<string>("MYSQLDB_HOST");
string databaseName = builder.Configuration.GetValue<string>("MYSQLDB_DATABASENAME");
var connectionUri = builder.Configuration.GetConnectionString("mysqldb");
var host = builder.Configuration.GetValue<string>("MYSQLDB_HOST");
var databaseName = builder.Configuration.GetValue<string>("MYSQLDB_DATABASENAME");
```

<Aside type="tip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ var pythonApp = builder.AddUvicornApp("api", "./api", "main:app")

The following environment variables are available in the Python application:

- `ConnectionStrings__oracledb` - The connection string for the Oracle database
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? I thought connection strings were still present.

- `ORACLEDB_HOST` - The hostname of the Oracle server
- `ORACLEDB_PORT` - The port number
- `ORACLEDB_USERNAME` - The username for authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ When you reference a `PostgresDatabaseResource` (a specific database), the follo
| `Username` | `[RESOURCE]_USERNAME` | The username for authenticating to the PostgreSQL server. |
| `Password` | `[RESOURCE]_PASSWORD` | The password for authenticating to the PostgreSQL server. |
| `DatabaseName` | `[RESOURCE]_DATABASENAME` | The name of the specific database. |
| `ConnectionString` | `ConnectionStrings__[RESOURCE]` | The full connection string for the database. |
| `JDBCConnectionString` | `[RESOURCE]_JDBCCONNECTIONSTRING` | The JDBC connection string for the database. |

Here's an example of how these properties are used when you call `WithReference`:
Expand All @@ -91,7 +90,7 @@ var myService = builder.AddProject<Projects.ExampleProject>()
.WithReference(postgresdb);
```

In this example, the `ExampleProject` will have access to environment variables like `POSTGRESDB_HOST`, `POSTGRESDB_PORT`, `POSTGRESDB_USERNAME`, `POSTGRESDB_PASSWORD`, `POSTGRESDB_DATABASENAME`, `POSTGRESDB_JDBCCONNECTIONSTRING`, and the connection string `ConnectionStrings__postgresdb`.
In this example, the `ExampleProject` will have access to environment variables like `POSTGRESDB_HOST`, `POSTGRESDB_PORT`, `POSTGRESDB_USERNAME`, `POSTGRESDB_PASSWORD`, `POSTGRESDB_DATABASENAME`, and `POSTGRESDB_JDBCCONNECTIONSTRING`.

## Enrich an Npgsql database context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ The SQL Server database resource inherits all properties from its parent `SqlSer
| Property Name | Description |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `DatabaseName` | The name of the database |
| `ConnectionString` | The connection string for the database, with the format `Server={Host},{Port};User ID={Username};Password={Password};Database={DatabaseName};Encrypt=true;TrustServerCertificate=false` |
| `JdbcConnectionString` | The JDBC connection string for the database, with the format `jdbc:sqlserver://{Host}:{Port};database={DatabaseName};user={Username};password={Password};encrypt=true;` |

For example, if you reference a database resource named `sqldb` in your AppHost project, the following environment variables will be available in the consuming project:
Expand All @@ -87,7 +86,6 @@ For example, if you reference a database resource named `sqldb` in your AppHost
- `SQLDB_USERNAME`
- `SQLDB_PASSWORD`
- `SQLDB_DATABASENAME`
- `ConnectionStrings__sqldb` (the full connection string)
- `SQLDB_JDBCCONNECTIONSTRING`

## Enrich a SQL Server database context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ In the AppHost, when you used the `WithReference` method to pass an Elasticsearc
Use the `GetValue()` method to obtain this environment variable in consuming projects:

```csharp title="C# - Obtain configuration properties"
string endpoint = builder.Configuration.GetValue<string>("ConnectionStrings__elasticsearch");
var endpoint = builder.Configuration.GetConnectionString("elasticsearch");
```

</Pivot>
Expand All @@ -188,6 +188,7 @@ const elasticsearchEndpoint = process.env.ConnectionStrings__elasticsearch;

</Pivot>


### Use Elasticsearch resources in client code

<Pivot id="csharp">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE
Use the `GetValue()` method to obtain these environment variables in consuming projects:

```csharp title="C# - Obtain configuration properties"
string connectionUri = builder.Configuration.GetValue<string>("ConnectionStrings__milvusdb");
string token = builder.Configuration.GetValue<string>("MILVUSDB_TOKEN");
var connectionUri = builder.Configuration.GetConnectionString("milvusdb");
var token = builder.Configuration.GetValue<string>("MILVUSDB_TOKEN");
```

</Pivot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ var pythonApp = builder.AddUvicornApp("api", "./api", "main:app")

The following environment variables are available in the Python application:

- `ConnectionStrings__milvusdb` - The connection string for the Milvus database
- `MILVUSDB_HOST` - The hostname of the Milvus server
- `MILVUSDB_PORT` - The gRPC port number
- `MILVUSDB_TOKEN` - The authentication token (format: `root:{password}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ var pythonApp = builder.AddUvicornApp("api", "./api", "main:app")

The following environment variables are available in the Python application:

- `ConnectionStrings__mongodb` - The connection string for the MongoDB database
- `MONGODB_HOST` - The hostname of the MongoDB server
- `MONGODB_PORT` - The port number
- `MONGODB_USERNAME` - The username for authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE
Use the `GetValue()` method to obtain these environment variables in consuming projects:

```csharp title="C# - Obtain configuration properties"
string connectionString = builder.Configuration.GetValue<string>("ConnectionStrings__qdrant");
string apiKey = builder.Configuration.GetValue<string>("QDRANT_APIKEY");
var connectionUri = builder.Configuration.GetConnectionString("qdrant");
var apiKey = builder.Configuration.GetValue<string>("QDRANT_APIKEY");
```

</Pivot>
Expand All @@ -183,7 +183,6 @@ string apiKey = builder.Configuration.GetValue<string>("QDRANT_APIKEY");
Use the `os.getenv()` method to obtain these environment variables in consuming projects:

```python title="Python - Obtain configuration properties"
connection_string = os.getenv("ConnectionStrings__qdrant")
api_key = os.getenv("QDRANT_APIKEY")
grpc_host = os.getenv("QDRANT_GRPCHOST")
grpc_port = os.getenv("QDRANT_GRPCPORT")
Expand All @@ -196,7 +195,6 @@ grpc_port = os.getenv("QDRANT_GRPCPORT")
Use the `process.env` property to obtain these environment variables in consuming projects:

```javascript title="JavaScript - Obtain configuration properties"
const connectionString = process.env.ConnectionStrings__qdrant;
const apiKey = process.env.QDRANT_APIKEY;
const grpcHost = process.env.QDRANT_GRPCHOST;
const grpcPort = process.env.QDRANT_GRPCPORT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ var pythonApp = builder.AddUvicornApp("api", "./api", "main:app")

The following environment variables are available in the Python application:

- `ConnectionStrings__qdrant` - The connection string for the Qdrant server
- `QDRANT_GRPCHOST` - The gRPC hostname of the Qdrant server
- `QDRANT_GRPCPORT` - The gRPC port number
- `QDRANT_HTTPHOST` - The HTTP hostname of the Qdrant server
Expand Down
Loading