Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions playground/publishers/Publishers.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
// 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.Azure;
// using Aspire.Hosting.Kubernetes;
using Aspire.Hosting.Azure;
using Aspire.Hosting.Docker;
using Aspire.Hosting.Kubernetes;

var builder = DistributedApplication.CreateBuilder(args);

builder.AddDockerCompose("docker-compose", options =>
{
options.DefaultContainerRegistry = "override.azurecr.io";
// Do stuff here.
});

builder.AddKubernetes("k8s", options =>
{
// Do stuff here.
});

builder.AddAzureContainerApps("aca", options =>
{
// Do stuff here.
});
builder.AddAzureContainerAppsInfrastructure();

builder.AddDockerCompose("docker-compose");

builder.AddKubernetes("k8s");

#pragma warning disable ASPIREAZURE001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

builder.AddAzurePublisher("azure");

#pragma warning restore ASPIREAZURE001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var param0 = builder.AddParameter("param0");
var param1 = builder.AddParameter("param1", secret: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</ItemGroup>

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.AppContainers" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.PostgreSQL" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.SqlServer" />
Expand Down
92 changes: 92 additions & 0 deletions playground/publishers/Publishers.AppHost/infra/api/api.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param api_containerport string

@secure()
param pg_password_value string

param azpg_outputs_connectionstring string

param outputs_azure_container_registry_managed_identity_id string

param outputs_azure_container_apps_environment_id string

param outputs_azure_container_registry_endpoint string

param api_containerimage string

resource api 'Microsoft.App/containerApps@2024-03-01' = {
name: 'api'
location: location
properties: {
configuration: {
secrets: [
{
name: 'connectionstrings--db'
value: '${'Host=pg;Port=5432;Username=${'postgres'};Password=${pg_password_value}'};Database=db'
}
]
activeRevisionsMode: 'Single'
ingress: {
external: true
targetPort: api_containerport
transport: 'http'
}
registries: [
{
server: outputs_azure_container_registry_endpoint
identity: outputs_azure_container_registry_managed_identity_id
}
]
}
environmentId: outputs_azure_container_apps_environment_id
template: {
containers: [
{
image: api_containerimage
name: 'api'
env: [
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES'
value: 'true'
}
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES'
value: 'true'
}
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY'
value: 'in_memory'
}
{
name: 'ASPNETCORE_FORWARDEDHEADERS_ENABLED'
value: 'true'
}
{
name: 'HTTP_PORTS'
value: api_containerport
}
{
name: 'ConnectionStrings__db'
secretRef: 'connectionstrings--db'
}
{
name: 'ConnectionStrings__azdb'
value: '${azpg_outputs_connectionstring};Database=azdb'
}
]
}
]
scale: {
minReplicas: 2
}
}
}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${outputs_azure_container_registry_managed_identity_id}': { }
}
}
}
67 changes: 67 additions & 0 deletions playground/publishers/Publishers.AppHost/infra/azpg/azpg.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param principalId string

param principalType string

param principalName string

resource azpg 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
name: take('azpg-${uniqueString(resourceGroup().id)}', 63)
location: location
properties: {
authConfig: {
activeDirectoryAuth: 'Enabled'
passwordAuth: 'Disabled'
}
availabilityZone: '1'
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
highAvailability: {
mode: 'Disabled'
}
storage: {
storageSizeGB: 32
}
version: '16'
}
sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
}
tags: {
'aspire-resource-name': 'azpg'
}
}

resource postgreSqlFirewallRule_AllowAllAzureIps 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2024-08-01' = {
name: 'AllowAllAzureIps'
properties: {
endIpAddress: '0.0.0.0'
startIpAddress: '0.0.0.0'
}
parent: azpg
}

resource azdb 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2024-08-01' = {
name: 'azdb'
parent: azpg
}

resource azpg_admin 'Microsoft.DBforPostgreSQL/flexibleServers/administrators@2024-08-01' = {
name: principalId
properties: {
principalName: principalName
principalType: principalType
}
parent: azpg
dependsOn: [
azpg
postgreSqlFirewallRule_AllowAllAzureIps
]
}

output connectionString string = 'Host=${azpg.properties.fullyQualifiedDomainName};Username=${principalName}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param dbsetup_containerport string

@secure()
param pg_password_value string

param outputs_azure_container_registry_managed_identity_id string

param outputs_azure_container_apps_environment_id string

param outputs_azure_container_registry_endpoint string

param dbsetup_containerimage string

resource dbsetup 'Microsoft.App/containerApps@2024-03-01' = {
name: 'dbsetup'
location: location
properties: {
configuration: {
secrets: [
{
name: 'connectionstrings--db'
value: '${'Host=pg;Port=5432;Username=${'postgres'};Password=${pg_password_value}'};Database=db'
}
]
activeRevisionsMode: 'Single'
ingress: {
external: false
targetPort: dbsetup_containerport
transport: 'http'
}
registries: [
{
server: outputs_azure_container_registry_endpoint
identity: outputs_azure_container_registry_managed_identity_id
}
]
}
environmentId: outputs_azure_container_apps_environment_id
template: {
containers: [
{
image: dbsetup_containerimage
name: 'dbsetup'
env: [
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES'
value: 'true'
}
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES'
value: 'true'
}
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY'
value: 'in_memory'
}
{
name: 'ASPNETCORE_FORWARDEDHEADERS_ENABLED'
value: 'true'
}
{
name: 'HTTP_PORTS'
value: dbsetup_containerport
}
{
name: 'ConnectionStrings__db'
secretRef: 'connectionstrings--db'
}
]
}
]
scale: {
minReplicas: 1
}
}
}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${outputs_azure_container_registry_managed_identity_id}': { }
}
}
}
Loading