Skip to content

Conversation

eerhardt
Copy link
Member

@eerhardt eerhardt commented Sep 9, 2025

Description

This pull request introduces support for Azure Container App Jobs in addition to existing Azure Container Apps functionality. It achieves this by adding new extension methods, annotation types, and context classes, and by refactoring the container app context management to handle both app and job types more flexibly.

Support for Azure Container App Jobs:

  • Added new extension methods PublishAsAzureContainerAppJob<T> for both ContainerResource and ProjectResource to allow resources to be published as Azure Container App Jobs, using a new configuration annotation. [1] [2]
  • Introduced the AzureContainerJobCustomizationAnnotation class, which enables custom configuration actions for Azure Container App Jobs.

Refactoring and Infrastructure:

  • Added a new abstract base class BaseContainerAppContext to encapsulate shared logic for both container apps and jobs, including environment variable, argument, and volume processing.
  • Updated ContainerAppEnvironmentContext to store and manage BaseContainerAppContext instances rather than just ContainerAppContext, and to instantiate the correct context type (app or job) based on resource annotations.

Fix #4366

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?

Copy link
Contributor

github-actions bot commented Sep 9, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11302

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11302"

@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label Sep 9, 2025
This pull request introduces support for Azure Container App Jobs in addition to existing Azure Container Apps functionality. It achieves this by adding new extension methods, annotation types, and context classes, and by refactoring the container app context management to handle both app and job types more flexibly.

Support for Azure Container App Jobs:

Added new extension methods PublishAsAzureContainerAppJob<T> for both ContainerResource and ProjectResource to allow resources to be published as Azure Container App Jobs, using a new configuration annotation. [1] [2]
Introduced the AzureContainerJobCustomizationAnnotation class, which enables custom configuration actions for Azure Container App Jobs.
Refactoring and Infrastructure:

Added a new abstract base class BaseContainerAppContext to encapsulate shared logic for both container apps and jobs, including environment variable, argument, and volume processing.
Updated ContainerAppEnvironmentContext to store and manage BaseContainerAppContext instances rather than just ContainerAppContext, and to instantiate the correct context type (app or job) based on resource annotations.

Fix dotnet#4366
@eerhardt eerhardt marked this pull request as ready for review September 12, 2025 05:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Azure Container App Jobs to the existing Aspire Azure Container Apps functionality. This enables scenarios where containers need to run as scheduled or manual jobs rather than continuously running services.

Key changes:

  • Added new PublishAsAzureContainerAppJob extension methods for both container and project resources
  • Introduced a new base class architecture to handle shared logic between container apps and jobs
  • Added validation to prevent conflicting container app and job configurations on the same resource

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
AzureContainerAppsTests.cs Added comprehensive test coverage for container app job functionality
ContainerAppJobContext.cs New context class for handling Azure Container App Job creation and configuration
ContainerAppEnvironmentContext.cs Updated to support both app and job contexts with proper validation
ContainerAppContext.cs Refactored to inherit from BaseContainerAppContext, removing duplicated code
BaseContainerAppContext.cs New abstract base class containing shared logic for both apps and jobs
AzureContainerJobCustomizationAnnotation.cs New annotation type for job customization
AzureContainerAppProjectExtensions.cs Added PublishAsAzureContainerAppJob extension method for project resources
AzureContainerAppContainerExtensions.cs Added PublishAsAzureContainerAppJob extension method for container resources
Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppProjectExtensions.cs:1

  • Missing closing angle bracket. Should be builder.AddProject<Projects.Api>().PublishAsAzureContainerAppJob
// Licensed to the .NET Foundation under one or more agreements.

/// </example>
/// </remarks>
[Experimental("ASPIREAZURE002", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
public static IResourceBuilder<T> PublishAsAzureContainerAppJob<T>(this IResourceBuilder<T> container, Action<AzureResourceInfrastructure, ContainerAppJob> configure)
Copy link
Member Author

Choose a reason for hiding this comment

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

@davidfowl - do I also need to do an extension method for Executables?

Copy link
Member

Choose a reason for hiding this comment

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

You can use IComputeResource

Copy link
Member

Choose a reason for hiding this comment

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

@eerhardt eerhardt added the azure Issues associated specifically with scenarios tied to using Azure label Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for container app job on deployment
2 participants