-
Notifications
You must be signed in to change notification settings - Fork 432
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
12 changed files
with
1,175 additions
and
6 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
21 changes: 21 additions & 0 deletions
21
src/Aspire.Hosting.Azure.ContainerApps/Aspire.Hosting.Azure.ContainerApps.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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework> | ||
<IsPackable>true</IsPackable> | ||
<PackageTags>aspire hosting azure</PackageTags> | ||
<Description>Azure container apps resource types for .NET Aspire.</Description> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<PackageIconFullPath>$(SharedDir)Azure_256x.png</PackageIconFullPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<MinCodeCoverage>0</MinCodeCoverage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Provisioning.AppContainers" /> | ||
<ProjectReference Include="..\Aspire.Hosting.Azure\Aspire.Hosting.Azure.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
74 changes: 74 additions & 0 deletions
74
src/Aspire.Hosting.Azure.ContainerApps/AzureContainerAppExtensions.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,74 @@ | ||
#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.ApplicationModel; | ||
using Aspire.Hosting.Lifecycle; | ||
using Azure.Provisioning.AppContainers; | ||
|
||
namespace Aspire.Hosting.Azure; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static class AzureContainerAppExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="builder"></param> | ||
/// <returns></returns> | ||
public static IDistributedApplicationBuilder AddContainerAppsInfrastructure(this IDistributedApplicationBuilder builder) | ||
{ | ||
builder.Services.TryAddLifecycleHook<AzureContainerAppsInfastructure>(); | ||
|
||
return builder; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="project"></param> | ||
/// <param name="configure"></param> | ||
/// <returns></returns> | ||
public static IResourceBuilder<ProjectResource> PublishAsContainerApp(this IResourceBuilder<ProjectResource> project, Action<ResourceModuleConstruct, ContainerApp> configure) | ||
{ | ||
if (!project.ApplicationBuilder.ExecutionContext.IsPublishMode) | ||
{ | ||
return project; | ||
} | ||
|
||
project.ApplicationBuilder.AddContainerAppsInfrastructure(); | ||
|
||
project.WithAnnotation(new ContainerAppCustomizationAnnotation(configure)); | ||
|
||
return project; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="container"></param> | ||
/// <param name="configure"></param> | ||
/// <returns></returns> | ||
public static IResourceBuilder<T> PublishAsContainerApp<T>(this IResourceBuilder<T> container, Action<ResourceModuleConstruct, ContainerApp> configure) where T : ContainerResource | ||
{ | ||
if (!container.ApplicationBuilder.ExecutionContext.IsPublishMode) | ||
{ | ||
return container; | ||
} | ||
|
||
container.ApplicationBuilder.AddContainerAppsInfrastructure(); | ||
|
||
container.WithAnnotation(new ContainerAppCustomizationAnnotation(configure)); | ||
|
||
return container; | ||
} | ||
} | ||
|
||
internal sealed class ContainerAppCustomizationAnnotation(Action<ResourceModuleConstruct, ContainerApp> configure) : IResourceAnnotation | ||
{ | ||
public Action<ResourceModuleConstruct, ContainerApp> Configure { get; } = configure; | ||
} |
Oops, something went wrong.