As developers, we love the benefits of containers, but they're not always easy to deploy. It can be a cumbersome process to build a container image, push it to a registry, and then set up infrastructure and deploy the container.
Azure Container Apps is a modern, fully-managed, serverless platform for running containers. While we don't have to manage infrastructure, it's still up to us to figure out how to build our container image and deploy it.
Today, we're introducing a preview feature in the Azure CLI that streamlines the process of deploying to Azure Container Apps in a single command. Whether your source code is on your local machine or in GitHub, "az containerapp up" is the only command you need to get your app running in Azure Container Apps.
How does it work?
"az containerapp up" is the newest in the rich set of Azure CLI commands for managing and deploying Azure Container Apps. It will:
- Provision your Azure resources, including: an Azure Container Apps environment, a container app, an Azure Container Registry, and an Azure Log Analytics workspace.
Build your container image and push it to the container registry. - Deploy your container to the container app.
If you want to, you can deploy to existing resources like Container Apps environments or use existing container registries. And you can update your app by running the same "az containerapp up" command again.
Install the containerapp CLI extension
"az containerapp up" is available in version 0.3.2 or above of the Container Apps Azure CLI extension. To make sure you have the latest version, run:
az extension add --name containerapp --upgrade
Deploy from a local source
"az containerapp up" can deploy from a local source. It needs a Dockerfile in your source directory.
Run the "az containerapp up" command, providing a name for the container app and the location of your source code.
az containerapp up --name my-app --source ./my-app
That's it! The command does everything needed to build and deploy the app:
- Creates a resource group.
- Creates an Azure Container Registry.
- Creates an Azure Log Analytics workspace.
- Creates an Azure Container Apps environment.
- Builds the container image and pushes it to the container registry.
- It builds the image using the Dockerfile in your source directory.
- The build runs in the cloud. It's fast and doesn't require Docker on your machine.
- Creates an Azure Container App.
- Deploys the container to the container app.
- If the Dockerfile includes an EXPOSE command, it'll also configure the app's ingress and target port.
When you make updates to the app, simply run the same "az containerapp up --name my-app --source ." command again to build and deploy it.
Deploy from GitHub
If you have an app in GitHub that you want to deploy, run the following command to set up all the resources and a GitHub Actions workflow to build and deploy the app:
az containerapp up --name my-app --repo https://github.com/my-name/my-app
You'll be prompted to log in to GitHub and, like with local source, the command does the rest.
- Creates a resource group.
- Creates an Azure Container Registry.
- Creates an Azure Log Analytics workspace.
- Creates an Azure Container Apps environment.
- Creates an Azure Container App.
- Sets up a GitHub Actions workflow to build and deploy the app.
To make updates to the app, push your changes to GitHub and the workflow will automatically build and deploy the app.
Customizing the command
By default, "az containerapp up" will use intelligent defaults to create your resources. You can override the defaults and even deploy to existing resources by providing the appropriate parameters.
To learn more, run "az containerapp up --help".
What's next?
The "az containerapp up" command is in preview. Use it to deploy to Azure Container Apps and let us know what you think!