Deploy containers to Azure Container Apps workload profiles using YAML
Published Oct 24 2023 09:00 AM 5,490 Views


The Azure Container Apps service enables you to run microservices and containerized applications on a serverless platform. With Container Apps, you enjoy the benefits of running containers while you leave behind the concerns of manually configuring cloud infrastructure and complex container orchestrators.  


The new workload profiles feature on Azure Container Apps enables users to determine the amount of compute and memory resources available to the container apps deployed in an environment. Different profile types like Consumption, Dedicated (general purpose), Dedicated (Memory Optimized) can be configured to fit your application needs. Workload Profiles is also a great way to segregate and better manage the different workloads per team or per workload. 


Why use YAML 

Deploying applications on Azure Container Apps can be achieved through various methods, each with its own strengths and use cases. The most common options include: 


- Azure Portal: This provides a user-friendly, graphical interface for creating and managing container apps. It's ideal for quick setups but may not be the best choice for automated and repetitive deployments. 


- Azure CLI: Azure CLI offers automation capabilities, but it follows an imperative model, which may not be the preferred approach for infrastructure as code (IaC) enthusiasts. 


- Azure CLI with --yaml Flag: Using the Azure CLI with the '--yaml' flag is an attractive option. It combines automation with the benefits of a declarative model, making it highly suitable for IaC. 


- Bicep Files: Bicep files are designed specifically for Azure Resource Manager templates and can be a robust choice for complex infrastructure deployments. 


The last two options, Azure CLI with '--yaml' and Bicep files, offer deployment flexibility by seamlessly integrating with continuous integration and continuous deployment (CI/CD) pipelines. These declarative files can be version-controlled using tools like Git, allowing for change tracking, collaboration, and maintaining a history of application configurations. 


One noteworthy advantage of using the Azure CLI with the '--yaml' flag over Bicep files is the simplicity and familiarity it brings. YAML, being a common, human-readable configuration format, is accessible to a broad audience, making it an attractive choice for developers and  


DevOps professionals. On the other hand, Bicep, while not overly complex, is a domain-specific language (DSL) that might require additional learning for your development team. 


Steps to deploy container apps using YAML to workload profiles 


A YAML file is a convenient way to configure a container app for reproducible deployments.   

Using a YAML file to input the container app configuration to the az containerapp create command in the Azure CLI is an efficient way to configure your container apps for reproducible deployments. Under the hood, Azure CLI converts YAML to JSON, and makes a PUT call (for create) or PATCH call (for update) to the service with the JSON as the body. In a way, all the YAML properties that are supported should be anything you can do in ARM. 


Here are the steps to deploy container apps using YAML: 


Create aca environment with workload profiles enabled 

Use the az command below to automatically create a consumption plan by default as the workload profile name is not set. Resource group, aca environment and location names are added as parameters in the command. 



$ az containerapp env create \ --enable-workload-profiles \ --resource-group "acawpyaml" \  --name "myacaenv" \  --location "eastus" 



Add new dedicated profile to existing environment 

There are various types and sizes of workload profiles and you can check the entire list of profile types. You can run 'az containerapp env workload-profile list-supported -l ' to check the options for your region.  

Use the command below to add a new dedicated workload profile type “D4” that has 4 vCPUs and 16 Gi memory to an existing ACA environment. Workload profile name parameter is used for providing a friendly workload profile name that will be referred in the yaml file to configure the container app deployment.   


Note: For testing purposes, minimum number of nodes is set as 1. For Production workloads, it is recommended to use minimum instances of 3 along with zone redundancy.  




$ az containerapp env workload-profile set --resource-group acawpyaml --name acawpyaml --workload-profile-type D4 --workload-profile-name dedicated_prof --min-nodes 1 --max-nodes 2 




After the command runs successfully, you can view the workload profiles created with consumption and dedicated D4 types. 




Create a YAML file defining container app configuration 

Here’s an example of what your YAML file might look like: 

In this example, we’re creating a container app with one container running hello world app on port 80 deployed to dedicated plan within the workload profiles. 

Workload profile name property on the yaml file determines the type to which the container app will be deployed to.  



location: eastus 

name: myapp-yaml-profile   #this is the name of the container app 

resourceGroup: myresourcegroup 

type: Microsoft.App/containerApps 


  managedEnvironmentId: /subscriptions/addyoursubscriptionid/resourceGroups/myresourcegroup/providers/Microsoft.App/managedEnvironments/myenvironment 

  workloadProfileName: "dedicated_prof" #your workload profile name 


    activeRevisionsMode: Multiple 


      external: true 

      allowInsecure: false 

      targetPort: 80 


        - latestRevision: true 

          weight: 100 

      transport: Auto 


    revisionSuffix: myrevision 


      - image: 

        name: myapp-yaml    #this is the name of the container executed in aca.  


          cpu: 0.25 

          memory: 0.5Gi 




Use the “az containerapp create command” in the Azure CLI to create your container app and specify the YAML file as input. 


To create your container group using this YAML file, run the following command in the Azure CLI: 



$ az containerapp create -n myapp-yaml-profile  -g acawpyaml  --yaml "HelloWorldApp.yaml"




This will create your container app based on the configuration specified in your YAML file. 



Using YAML files is an efficient way to configure your Azure Container Apps for reproducible deployments. By following these simple steps, you can easily deploy your container apps using YAML. 


Feel free to reach out with any questions about the blog or maybe even proposals on future blog posts! 


A big thank you goes to our specialists in these subject areas, make sure to follow them for any updates or reach out to them directly:

Version history
Last update:
‎Oct 24 2023 07:27 AM
Updated by: