Share via

Blue/Green Deployment Strategy for .NET Aspire + Azure Container Apps + Azure Developer CLI

Faisal Riaz 150 Reputation points
2026-05-07T11:05:36.3633333+00:00

We have a production environment built using .NET Aspire, deployed to Azure Container Apps (ACA).

Our deployments are primarily done through a CI/CD pipeline configured using azd pipeline config (Azure Developer CLI generated pipeline). As a fallback mechanism, we occasionally use azd up manually if the pipeline is unavailable or requires emergency deployment.

Current architecture includes:

  • Azure Application Gateway v2 (WAF)
  • Internal Azure Container Apps Environment
  • Multiple container apps:
    • portal-app
      • admin-app
        • portal-api
          • admin-api
            • background jobs
            • Private DNS Zones
            • Azure Key Vault
            • IAM VM / NGINX reverse proxy
            • Private endpoints for DB and Key Vault
            • Internal Load Balancer
            • Managed identities

Current Deployment Model

  • CI/CD pipeline generated and configured using:
    • azd pipeline config
  • Infrastructure and application deployment managed through:
    • Azure Developer CLI (azd)
    • .NET Aspire orchestration
  • Emergency/manual deployments are occasionally executed using:
    • azd up

Currently, deployments update the existing Azure Container Apps environment directly.

Requirement

Clients are requesting a Blue/Green deployment strategy with:

  • Near-zero downtime
  • Easy rollback capability
  • Ability to validate a new release before switching production traffic
  • Minimal impact on private networking and internal services
  • Compatibility with:
    • .NET Aspire
    • Azure Developer CLI (azd)
    • Existing CI/CD pipelines

Questions

  1. What is the recommended approach for implementing Blue/Green deployments with Azure Container Apps in this type of architecture?
  2. Considering we use .NET Aspire and azd pipeline config, what is the Microsoft-recommended deployment pattern?
  3. Should we:
    • Maintain separate Container Apps environments (blue/green)?
    • Maintain separate Aspire environments/stamps?
    • Use separate Application Gateway backend pools?
  4. How does Blue/Green deployment work when using:
    • Internal-only ACA ingress
    • Application Gateway WAF
    • Private DNS Zones
    • Managed identities
    • Private endpoints
    • VNet peering
  5. How should CI/CD pipelines generated via azd pipeline config be adapted to support:
    • Blue/Green deployments
    • Pre-production validation
    • Automated rollback
    • Traffic switching
  6. What are the best practices for:
    • Secret and certificate management
    • Rollback strategy
    1. Are there any Microsoft reference architectures, sample repositories, or enterprise guidance for Blue/Green deployments using:
      • Azure Container Apps
        • .NET Aspire
          • Azure Developer CLI (azd)

Any recommendations, production experiences, or official guidance would be greatly appreciated.

Azure Container Apps
Azure Container Apps

An Azure service that provides a general-purpose, serverless container platform.


Answer accepted by question author

  1. Pravallika KV 15,460 Reputation points Microsoft External Staff Moderator
    2026-05-08T10:52:19.71+00:00

    Faisal Riaz, Please find responses to your questions below:

    1. Changes required in Aspire.AppHost Program.cs

    In most cases, no major changes are required in Aspire.AppHost Program.cs.

    Blue/Green deployment with Azure Container Apps is primarily handled through:

    • ACA revisions
    • Revision labels
    • Traffic switching
    • CI/CD orchestration

    Your Aspire AppHost can generally remain unchanged.

    Optionally, you may add deployment slot/environment metadata, logging tags, telemetry attributes

    Example:

    • DEPLOYMENT_SLOT = blue/green
    • revision identifier for diagnostics

    However, separate Aspire manifests or separate AppHost projects are typically NOT required for ACA revision-based Blue/Green deployments.

    1. Blue/Green deployment suffix

    Yes, using revision suffixes is recommended.

    However, the suffix should normally be added during deployment/pipeline execution, not directly inside the application code.

    Recommended approach:

    • Add revision suffix in Azure CLI deployment commands within the pipeline.

    Example: az containerapp update --revision-suffix green-$(Build.BuildId)

    This allows ACA to create separate revisions such as:

    • portal-api--blue-123
    • portal-api--green-124

    This is the preferred enterprise approach because:

    • deployment logic stays outside application code
    • easier rollback
    • easier automation
    1. Changes required in infra/bicep

    Yes, some infra changes are required. Most important change is enabling multiple active revisions in Azure Container Apps.

    Example: activeRevisionsMode: 'multiple'

    Without this configuration, ACA replaces the old revision automatically, which prevents Blue/Green deployment behavior.

    Regarding automatic updates:

    • Aspire manifest/AppHost changes do NOT automatically handle all ACA revision settings.
    • It is recommended to explicitly define revision configuration inside your Bicep/IaC templates.

    Usually only minimal Bicep changes are required:

    • activeRevisionsMode
    • optional ingress traffic configuration

    No major redesign of networking resources should be necessary.

    1. Changes required in existing azd pipeline YAML Yes, the pipeline requires the most significant changes for Blue/Green deployment.

    Recommended flow within the SAME pipeline:

    • Build image
    • Deploy Green revision
    • Assign 0% traffic initially
    • Run validation/smoke tests
    • Switch traffic to Green
    • Keep Blue revision available for rollback
    • Rollback automatically if validation fails

    Recommended deployment pattern:

    Build → Deploy Green Revision → Validate Green → Manual Approval (optional) → Switch Traffic → Monitor → Retain Blue for rollback window

    Traffic switching can be performed using: az containerapp ingress traffic set

    Example: az containerapp ingress traffic set --label-weight blue=0 green=100

    Rollback: az containerapp ingress traffic set --label-weight blue=100 green=0

    A single pipeline is generally recommended instead of maintaining separate Blue/Green pipelines because:

    • easier orchestration
    • simpler approvals
    • centralized rollback logic
    • better traceability
    1. Sequential deployment with templates Sequential deployment is completely fine and actually aligns well with Blue/Green strategies.

    Recommended approach:

    • Deploy all services sequentially to Green revisions first
    • Validate the full environment
    • Switch traffic only after the entire deployment succeeds

    This avoids version mismatch scenarios between APIs/frontend/background services.

    1. Effect on cache and background services This is an important consideration.

    Cache: If shared cache (Redis etc.) is used, Blue and Green revisions will typically share the same cache.

    Recommended best practices:

    • Keep cache contracts backward compatible
    • Avoid breaking serialization changes
    • Prefer versioned cache keys if schema changes occur

    Example: customer:v2:123 instead of: customer:123

    Background services / workers: This area requires extra attention.

    Potential issue:

    • Both Blue and Green worker revisions may process the same queue simultaneously
    • This can lead to duplicate processing or race conditions

    Recommended approach:

    • APIs/UI → use Blue/Green revisions
    • Background workers → keep only one active revision

    For workers/consumers/schedulers:

    • scale old revision to 0 before enabling new revision OR
    • deploy workers separately from API traffic switching

    This is usually the safest enterprise pattern for queue-based workloads.

    Overall recommendation:

    For your current architecture, the recommended production approach is:

    • Single ACA Environment
    • Multiple ACA revisions
    • Revision labels (blue/green)
    • Traffic switching through ACA ingress
    • Same App Gateway/WAF
    • Same Private DNS
    • Same Key Vault and private endpoints
    • Pipeline-driven validation and rollback

    Was this answer helpful?

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.