-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for customizing container apps in ACA via the CDK
- Added Aspire.Hosting.Azure.ContainerApps. This exposes 3 APIs used to configure and customize container app resources. - Added deployment target support to project and container resources in the manifest writer. This allows developers to express that a project/container gets deployed using the nested resource type. This requires a branch of azd to wire up and test.
- Loading branch information
Showing
29 changed files
with
1,889 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...und/AzureContainerApps/AzureContainerApps.ApiService/AzureContainerApps.ApiService.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<AspireProjectOrPackageReference Include="Aspire.Azure.Storage.Blobs" /> | ||
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
6 changes: 6 additions & 0 deletions
6
...round/AzureContainerApps/AzureContainerApps.ApiService/AzureContainerApps.ApiService.http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@CosmosEndToEnd.ApiService_HostAddress = http://localhost:5193 | ||
|
||
GET {{CosmosEndToEnd.ApiService_HostAddress}}/ | ||
Accept: application/json | ||
|
||
### |
35 changes: 35 additions & 0 deletions
35
playground/AzureContainerApps/AzureContainerApps.ApiService/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Azure.Storage.Blobs; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.AddServiceDefaults(); | ||
|
||
builder.AddAzureBlobClient("blobs"); | ||
|
||
var app = builder.Build(); | ||
|
||
app.MapDefaultEndpoints(); | ||
app.MapGet("/", async (BlobServiceClient bsc) => | ||
{ | ||
var container = bsc.GetBlobContainerClient("mycontainer"); | ||
await container.CreateIfNotExistsAsync(); | ||
var blobNameAndContent = Guid.NewGuid().ToString(); | ||
await container.UploadBlobAsync(blobNameAndContent, new BinaryData(blobNameAndContent)); | ||
var blobs = container.GetBlobsAsync(); | ||
var blobNames = new List<string>(); | ||
await foreach (var blob in blobs) | ||
{ | ||
blobNames.Add(blob.Name); | ||
} | ||
return blobNames; | ||
}); | ||
|
||
app.Run(); |
14 changes: 14 additions & 0 deletions
14
playground/AzureContainerApps/AzureContainerApps.ApiService/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5193", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
playground/AzureContainerApps/AzureContainerApps.ApiService/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
playground/AzureContainerApps/AzureContainerApps.ApiService/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
27 changes: 27 additions & 0 deletions
27
playground/AzureContainerApps/AzureContainerApps.AppHost/AzureContainerApps.AppHost.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsAspireHost>true</IsAspireHost> | ||
<UserSecretsId>9dc69458-f2b4-4306-9dc5-f7b8e398a3a9</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\..\KnownResourceNames.cs" Link="KnownResourceNames.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.ContainerApps" /> | ||
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.CosmosDB" /> | ||
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.Storage" /> | ||
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.Redis" /> | ||
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" /> | ||
<AspireProjectOrPackageReference Include="Aspire.Hosting.Redis" /> | ||
|
||
<ProjectReference Include="..\AzureContainerApps.ApiService\AzureContainerApps.ApiService.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
49 changes: 49 additions & 0 deletions
49
playground/AzureContainerApps/AzureContainerApps.AppHost/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma warning disable AZPROVISION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. | ||
// 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; | ||
|
||
var builder = DistributedApplication.CreateBuilder(args); | ||
|
||
// Testing secret parameters | ||
var param = builder.AddParameter("secretparam", "fakeSecret", secret: true); | ||
|
||
// Testing volumes | ||
var redis = builder.AddRedis("cache") | ||
.WithLifetime(ContainerLifetime.Persistent) | ||
.WithDataVolume(); | ||
|
||
// Testing secret outputs | ||
var cosmosDb = builder.AddAzureCosmosDB("account") | ||
.RunAsEmulator(c => c.WithLifetime(ContainerLifetime.Persistent)) | ||
.AddDatabase("db"); | ||
|
||
// Testing a connection string | ||
var blobs = builder.AddAzureStorage("storage") | ||
.RunAsEmulator(c => c.WithLifetime(ContainerLifetime.Persistent)) | ||
.AddBlobs("blobs"); | ||
|
||
builder.AddProject<Projects.AzureContainerApps_ApiService>("api") | ||
.WithExternalHttpEndpoints() | ||
.WithReference(blobs) | ||
.WithReference(redis) | ||
.WithReference(cosmosDb) | ||
.WithEnvironment("VALUE", param) | ||
.PublishAsContainerApp((module, app) => | ||
{ | ||
// Scale to 0 | ||
app.Template.Value!.Scale.Value!.MinReplicas = 0; | ||
}); | ||
|
||
#if !SKIP_DASHBOARD_REFERENCE | ||
// This project is only added in playground projects to support development/debugging | ||
// of the dashboard. It is not required in end developer code. Comment out this code | ||
// or build with `/p:SkipDashboardReference=true`, to test end developer | ||
// dashboard launch experience, Refer to Directory.Build.props for the path to | ||
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the | ||
// artifacts dir). | ||
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard); | ||
#endif | ||
|
||
builder.Build().Run(); | ||
|
44 changes: 44 additions & 0 deletions
44
playground/AzureContainerApps/AzureContainerApps.AppHost/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:15887;http://localhost:15888", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16157", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17307", | ||
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true" | ||
} | ||
}, | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:15888", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16157", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17308", | ||
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true", | ||
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true" | ||
} | ||
}, | ||
"generate-manifest": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"dotnetRunMessages": true, | ||
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json", | ||
"applicationUrl": "http://localhost:15888", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16157" | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
playground/AzureContainerApps/AzureContainerApps.AppHost/account.module.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@description('The location for the resource(s) to be deployed.') | ||
param location string = resourceGroup().location | ||
|
||
param keyVaultName string | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2019-09-01' existing = { | ||
name: keyVaultName | ||
} | ||
|
||
resource account 'Microsoft.DocumentDB/databaseAccounts@2024-05-15-preview' = { | ||
name: take('account-${uniqueString(resourceGroup().id)}', 44) | ||
location: location | ||
properties: { | ||
locations: [ | ||
{ | ||
locationName: location | ||
failoverPriority: 0 | ||
} | ||
] | ||
consistencyPolicy: { | ||
defaultConsistencyLevel: 'Session' | ||
} | ||
databaseAccountOfferType: 'Standard' | ||
} | ||
kind: 'GlobalDocumentDB' | ||
tags: { | ||
'aspire-resource-name': 'account' | ||
} | ||
} | ||
|
||
resource db 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2024-05-15-preview' = { | ||
name: 'db' | ||
location: location | ||
properties: { | ||
resource: { | ||
id: 'db' | ||
} | ||
} | ||
parent: account | ||
} | ||
|
||
resource connectionString 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = { | ||
name: 'connectionString' | ||
properties: { | ||
value: 'AccountEndpoint=${account.properties.documentEndpoint};AccountKey=${account.listKeys().primaryMasterKey}' | ||
} | ||
parent: keyVault | ||
} |
Oops, something went wrong.