Blog Post

Apps on Azure Blog
2 MIN READ

Command Override in Azure Container Apps /Container App Job

sheetal_06's avatar
sheetal_06
Icon for Microsoft rankMicrosoft
Mar 12, 2024

Introduction

Azure Container Apps (ACA) provides a flexible and scalable platform for deploying containerized applications. One powerful feature it offers is the ability to customize startup commands and override default CMD or ENTRYPOINT defined in a Dockerfile. In this blog, we'll explore how to leverage the "Command Override" option using various methods in ACA and Container App Jobs.

 

Understanding Command Overrides

Command overrides come in handy when you need to execute specific CMD or change the ENTRYPOINT of your container at runtime.

 

Example:

If one wants to run "index.js" during the start of the app, but as per line number 14 in below image, the "server.js" file will execute.

It can be achieved by providing "node", "index.js" to Command Override field in ACA, in easy words, the Dockerfile will be updated for that particular revision.

 

Parameters for Command Override

Before we dive into the methods, let's understand the key parameters:

 

  • --args: Used to add startup commands during image deployment.
  • --command: Overrides the default ENTRYPOINT or command defined in the Dockerfile. If you are overriding using a file present in specific path of the directory, then provide the path of the file from the root "/" . It reads the path and finds the file from the Kubernetes level.  

 

Methods of Command Overrides

 

  1. Azure CLI

When using the Azure Command-Line Interface (CLI) to create an Azure Container App, you can specify the command override using the "--command" parameter. Here's an example:

 

 

 

az containerapp create --name mycontainer --image myimage:latest --command "python, /some/path/python.py"

 

 

 

 

  1. Azure Portal

The Azure portal provides a user-friendly interface for managing container configurations. To use Command Override:

 

  1. Navigate to the Azure portal > Azure Container Apps.
  2. Go to the container configuration section while editing or creating a container.
  3. Check out the "Command Override" property.
  4. Provide a comma-separated list of strings without quotes. Example:

python, /some/path/python.py

 

This approach offers a visual and intuitive way to customize commands without delving into the command-line intricacies.

 

  1. Resource Manager Template

For those who prefer infrastructure-as-code, Resource Manager templates (Bicep or ARM templates) provide a structured way to define configurations. To specify the command line property as an array of strings, use the following syntax:

 

 

 

"properties": {

  "command": ["python", "/some/path/python.py"]

}

 

 

 

Conclusion

The Command Override in Azure Container Apps and Container App Jobs opens up possibilities for tailoring your containerized applications. Experiment with different commands and entry points to find the configuration that best suits your application's needs. Happy developing!

Updated Mar 12, 2024
Version 3.0
  • Benjiiim's avatar
    Benjiiim
    Copper Contributor

    Thanks sheetal_06 

    What about startup command arguments?

    As far as I understand, we can define them thanks to the args setting when deploying through an ARM or bicep template, right?

    However, I can't find this parameter in the portal. Am I missing something?