Skip to content

Commit

Permalink
Unify how we resolve argument and env variables (#7360)
Browse files Browse the repository at this point in the history
* Unify how we resolve argument and env variables
- De-dupe the logic that we use to resolve environment variables and arguments in run and publish mode. This was done for both tests and product code. We now have a single way to resolve values.
- Updated manifests

* Fixed ArgumentEvaluator

* Pass the container host name

* Fix the container host name
  • Loading branch information
davidfowl authored Feb 1, 2025
1 parent 7792c8f commit 12e92d7
Show file tree
Hide file tree
Showing 18 changed files with 603 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ resource mycontainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/contain
parent: mydatabase
}

resource leases 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-08-15' = {
name: 'leases'
location: location
properties: {
resource: {
id: 'leases'
partitionKey: {
paths: [
'/id'
]
}
}
}
parent: mydatabase
}

resource cosmosdb_roleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2024-08-15' existing = {
name: '00000000-0000-0000-0000-000000000002'
parent: cosmosdb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"elasticsearch": {
"type": "container.v0",
"connectionString": "http://elastic:{elasticsearch-password.value}@{elasticsearch.bindings.http.host}:{elasticsearch.bindings.http.port}",
"image": "docker.io/library/elasticsearch:8.15.3",
"image": "docker.io/library/elasticsearch:8.17.0",
"volumes": [
{
"name": "elasticsearch.apphost-93fd2337c1-elasticsearch-data",
"name": "elasticsearch.apphost-7490553fdf-elasticsearch-data",
"target": "/usr/share/elasticsearch/data",
"readOnly": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"oracle": {
"type": "container.v0",
"connectionString": "user id=system;password={oracle-password.value};data source={oracle.bindings.tcp.host}:{oracle.bindings.tcp.port}",
"image": "container-registry.oracle.com/database/free:23.5.0.0",
"image": "container-registry.oracle.com/database/free:23.6.0.0",
"env": {
"ORACLE_PWD": "{oracle-password.value}"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pg1": {
"type": "container.v0",
"connectionString": "Host={pg1.bindings.tcp.host};Port={pg1.bindings.tcp.port};Username=postgres;Password={pg1-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand All @@ -27,7 +27,7 @@
"pg2": {
"type": "container.v0",
"connectionString": "Host={pg2.bindings.tcp.host};Port={pg2.bindings.tcp.port};Username=postgres;Password={pg2-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand All @@ -50,7 +50,7 @@
"pg3": {
"type": "container.v0",
"connectionString": "Host={pg3.bindings.tcp.host};Port={pg3.bindings.tcp.port};Username=postgres;Password={pg3-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand All @@ -77,7 +77,7 @@
"pg4": {
"type": "container.v0",
"connectionString": "Host={pg4.bindings.tcp.host};Port={pg4.bindings.tcp.port};Username=postgres;Password={pg4-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand All @@ -100,7 +100,7 @@
"pg5": {
"type": "container.v0",
"connectionString": "Host={pg5.bindings.tcp.host};Port={pg5.bindings.tcp.port};Username=postgres;Password={pg5-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand All @@ -123,7 +123,7 @@
"pg6": {
"type": "container.v0",
"connectionString": "Host={pg6.bindings.tcp.host};Port={pg6.bindings.tcp.port};Username=postgres;Password={pg6-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand Down Expand Up @@ -169,7 +169,7 @@
"pg11": {
"type": "container.v0",
"connectionString": "Host={pg11.bindings.tcp.host};Port={pg11.bindings.tcp.port};Username=postgres;Password={pg11-password.value}",
"image": "docker.io/library/postgres:17.0",
"image": "docker.io/library/postgres:17.2",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
Expand Down
90 changes: 90 additions & 0 deletions playground/Stress/Stress.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,96 @@
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0000": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0001": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0002": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0003": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0004": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0005": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0006": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0007": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0008": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
},
"empty-0009": {
"type": "project.v0",
"path": "../Stress.Empty/Stress.Empty.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory"
}
}
}
}
4 changes: 2 additions & 2 deletions playground/kafka/KafkaBasic.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"kafka": {
"type": "container.v0",
"connectionString": "{kafka.bindings.tcp.host}:{kafka.bindings.tcp.port}",
"image": "docker.io/confluentinc/confluent-local:7.7.1",
"image": "docker.io/confluentinc/confluent-local:7.8.0",
"env": {
"KAFKA_LISTENERS": "PLAINTEXT://localhost:29092,CONTROLLER://localhost:29093,PLAINTEXT_HOST://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:9093",
"KAFKA_LISTENER_SECURITY_PROTOCOL_MAP": "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT",
Expand Down Expand Up @@ -54,7 +54,7 @@
"kafka2": {
"type": "container.v0",
"connectionString": "{kafka2.bindings.tcp.host}:{kafka2.bindings.tcp.port}",
"image": "docker.io/confluentinc/confluent-local:7.7.1",
"image": "docker.io/confluentinc/confluent-local:7.8.0",
"env": {
"KAFKA_LISTENERS": "PLAINTEXT://localhost:29092,CONTROLLER://localhost:29093,PLAINTEXT_HOST://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:9093",
"KAFKA_LISTENER_SECURITY_PROTOCOL_MAP": "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT",
Expand Down
17 changes: 13 additions & 4 deletions playground/keycloak/Keycloak.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,28 @@
],
"volumes": [
{
"name": "keycloak.apphost-18509cd2da-keycloak-data",
"name": "keycloak.apphost-28dd42043c-keycloak-data",
"target": "/opt/keycloak/data",
"readOnly": false
}
],
"env": {
"KEYCLOAK_ADMIN": "admin",
"KEYCLOAK_ADMIN_PASSWORD": "{keycloak-password.value}"
"KC_BOOTSTRAP_ADMIN_USERNAME": "admin",
"KC_BOOTSTRAP_ADMIN_PASSWORD": "{keycloak-password.value}",
"KC_HEALTH_ENABLED": "true"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 8080
},
"management": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 9000
}
}
},
Expand All @@ -44,7 +51,8 @@
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"HTTP_PORTS": "{apiservice.bindings.http.targetPort}",
"services__keycloak__http__0": "{keycloak.bindings.http.url}"
"services__keycloak__http__0": "{keycloak.bindings.http.url}",
"services__keycloak__management__0": "{keycloak.bindings.management.url}"
},
"bindings": {
"http": {
Expand All @@ -69,6 +77,7 @@
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"HTTP_PORTS": "{webfrontend.bindings.http.targetPort}",
"services__keycloak__http__0": "{keycloak.bindings.http.url}",
"services__keycloak__management__0": "{keycloak.bindings.management.url}",
"services__apiservice__http__0": "{apiservice.bindings.http.url}",
"services__apiservice__https__0": "{apiservice.bindings.https.url}"
},
Expand Down
2 changes: 1 addition & 1 deletion playground/signalr/SignalR.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
}
}
}
}
}
44 changes: 44 additions & 0 deletions playground/signalr/SignalR.AppHost/signalrDefault.module.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param principalType string

param principalId string

resource signalrDefault 'Microsoft.SignalRService/signalR@2024-03-01' = {
name: take('signalrDefault-${uniqueString(resourceGroup().id)}', 63)
location: location
properties: {
cors: {
allowedOrigins: [
'*'
]
}
features: [
{
flag: 'ServiceMode'
value: 'Default'
}
]
}
kind: 'SignalR'
sku: {
name: 'Free_F1'
capacity: 1
}
tags: {
'aspire-resource-name': 'signalrDefault'
}
}

resource signalrDefault_SignalRAppServer 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(signalrDefault.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '420fcaa2-552c-430f-98ca-3264be4806c7'))
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '420fcaa2-552c-430f-98ca-3264be4806c7')
principalType: principalType
}
scope: signalrDefault
}

output hostName string = signalrDefault.properties.hostName
54 changes: 54 additions & 0 deletions playground/signalr/SignalR.AppHost/signalrServerless.module.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param principalType string

param principalId string

resource signalrServerless 'Microsoft.SignalRService/signalR@2024-03-01' = {
name: take('signalrServerless-${uniqueString(resourceGroup().id)}', 63)
location: location
properties: {
cors: {
allowedOrigins: [
'*'
]
}
features: [
{
flag: 'ServiceMode'
value: 'Serverless'
}
]
}
kind: 'SignalR'
sku: {
name: 'Free_F1'
capacity: 1
}
tags: {
'aspire-resource-name': 'signalrServerless'
}
}

resource signalrServerless_SignalRAppServer 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(signalrServerless.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '420fcaa2-552c-430f-98ca-3264be4806c7'))
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '420fcaa2-552c-430f-98ca-3264be4806c7')
principalType: principalType
}
scope: signalrServerless
}

resource signalrServerless_SignalRRestApiOwner 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(signalrServerless.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'fd53cd77-2268-407a-8f46-7e7863d0f521'))
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'fd53cd77-2268-407a-8f46-7e7863d0f521')
principalType: principalType
}
scope: signalrServerless
}

output hostName string = signalrServerless.properties.hostName
Loading

0 comments on commit 12e92d7

Please sign in to comment.