February 20th, 2025

Deploying WebJobs to Azure Container Apps

Developer Support
Cloud Solution Architects

Debjyoti Ganguly walks through the process of migrating existing WebJobs to Azure Container App Jobs, highlighting the benefits and providing practical steps to implement this migration effectively


Introduction As businesses scale, the need for a robust and scalable environment for running background jobs becomes essential. Azure Container App Jobs offer a modern, scalable, and containerized solution for running background jobs, providing significant benefits over traditional Azure WebJobs. This guide will walk you through the process of migrating existing WebJobs to Azure Container App Jobs, highlighting the benefits and providing practical steps to implement this migration effectively.

Benefits of Azure Container App Jobs over Azure WebJobs

  • Scalability: Automatically scales based on demand without manual intervention.
  • Flexibility: Supports a wide range of runtime environments and programming languages.
  • Isolation: Each job runs in its isolated container, enhancing security and reliability.
  • Seamless Integration: Easily integrates with other Azure services like Azure Key Vault, SQL Server, and Azure Storage.

 

1.1.1 Quick Flow of the Implementation

A screenshot of a computer screen AI-generated content may be incorrect.

Azure Resource Deployment as Infra Setup

Below security measures and recommendations should be implemented while deploying the Azure Container App Managed Environment and Azure Container Registry (ACR) to ensure robust and secure infrastructure.

Security Measures and Recommendations

  1. System-Assigned Managed Identity
  2. Network Isolation with Private endpoints
  3. Role-Based Access Control (RBAC)
  4. Container Image Scanning using Microsoft Cloud Defender
  5. Data Encryption
  6. Audit and Monitoring with Application Insights

By implementing these security measures, we ensure that our infrastructure setup for Azure Container Apps and ACR is secure, resilient, and compliant with best practices, providing a solid foundation for running containerized workloads in the cloud.

Note – Check out my public GitHub Gist, which contains a sample of Infrastructure as Code (IAC) / Bicep that you can use to set up your resources and develop according to your requirements.

https://gist.github.com/Debjyoti30/ff3bec45dbe2935cfd3d0af7e4bcce1e

Push your changes using Pull request to the Infra deployment branch and once merged it will trigger your infra-deployment pipeline.

Infra-deployment Pipeline :-

A screenshot of a computer AI-generated content may be incorrect.

To fork the same – https://gist.github.com/Debjyoti30/ac765b9fdc1f8dca1f9da8833d14cb1f

CI/CD Setup for the Image build and Azure Container app job provision:- 1. Pack and push Dockerfile as an artifact.

A screenshot of a computer program AI-generated content may be incorrect.

To fork this sample – https://gist.github.com/Debjyoti30/bf16184bfd45e9c749ca19d030fb7d35

Task Significance in the Pipeline

ArchiveFiles@2 Task:

This task packages the Dockerfile and related files from the specified sourcePath.

The files are archived into a .zip file.

The archive file is named using the packageName and packageVersion variables and saved to the outputPath.

PublishBuildArtifacts@1 Task:

This task publishes the packaged .zip file to Azure Artifacts.

The package can later be retrieved and used by the CD pipeline for building the Docker image.

This pipeline captures the intent of packaging the Dockerfile and its dependencies into an artifact that can be consumed by subsequent stages, aligning with your goal of separating the packaging and building processes.

 

2. Download the Artifact and create Azure Container App Job ( CD Setup )

Pipeline Config – https://gist.github.com/Debjyoti30/518fe40eb892d020badb29ca884836a2

Task Significance in the Pipeline

  1. DownloadPipelineArtifact@2 Task:
    • Downloads the Dockerfile package from Azure Artifacts to the pipeline workspace.
  2. Bash@3 Task (Build and Push):
    • Uses the Azure CLI to log in to ACR.
    • Builds the Docker image using the downloaded Dockerfile.
    • Tags the image with the Azure Pipeline’s build ID.
    • Pushes the Docker image to the ACR.
  3. Bash@3 Task (Create Container App Job):
    • Uses the Azure CLI to create the Azure Container App Job from the pushed image, using the ACR image and the specified environment.

 

Author

Developer Support
Cloud Solution Architects

Microsoft Developer Support helps software developers rapidly build and deploy quality applications for Microsoft platforms.

0 comments