{
"$type": "site.standard.document",
"canonicalUrl": "https://johnnyreilly.com/posts/azure-container-apps-bicep-and-github-actions",
"description": "Learn how to deploy an Azure Container App to Azure with Bicep and GitHub Actions. A basic template is provided for deployment.",
"path": "/posts/azure-container-apps-bicep-and-github-actions",
"publishedAt": "2021-12-19T00:00:00.000Z",
"site": "at://did:plc:yy3apqjlms24kso7ahn7lbmb/site.standard.publication/3mova7c4nho2b",
"tags": [
"bicep",
"github actions",
"azure container apps"
],
"textContent": "Azure Container Apps are an exciting way to deploy containers to Azure. This post shows how to deploy the infrastructure for an Azure Container App to Azure using Bicep and GitHub Actions. The Azure Container App documentation features quickstarts for deploying your first container app using both the Azure Portal and the Azure CLI. These are great, but there's a gap if you prefer to deploy using Bicep and you'd like to get your CI/CD setup right from the beginning. This post aims to fill that gap.\n\nIf you're interested in building your own containers as well, it's worth looking at this follow up post.\n\n\n\nUpdated 02/05/2022\n\nThis post has been updated to reflect the migration of Azure Container Apps from the Microsoft.Web namespace to the Microsoft.App namespace in March 2022. See: https://github.com/microsoft/azure-container-apps/issues/109\n\nBicep\n\nLet's begin with the Bicep required to deploy an Azure Container App.\n\nIn our new repository we'll create an infra directory, into which we'll place a main.bicep file which will contain our Bicep template.\n\nI've pared this down to the simplest Bicep template that I can; it only requires a name parameter:\n\nSome things to note from the template:\n\n- We're deploying three resources; a container app, a kube environment and an operational insights.\n- Just like the official quickstarts we're going to use the containerapps-helloworld image.\n\nSetting up a resource group\n\nIn order that you can deploy your Bicep, we're going to need a resource group to send it to. Right now, Azure Container Apps aren't available everywhere. So we're going to create ourselves a resource group in North Europe which does support ACAs:\n\nDeploying with the Azure CLI\n\nWith this resource group in place, we could simply deploy using the Azure CLI like so:\n\nDeploying with GitHub Actions\n\nHowever, we're aiming to set up a GitHub Action to do this for us. We'll create a .github/workflows/deploy.yaml file in our repository:\n\nThe above GitHub action is very simple. It:\n\n1. Logs into Azure using some AZURE_CREDENTIALS we'll set up in a moment.\n2. Invokes the Azure CLI to deploy our Bicep template.\n\nLet's create that AZURE_CREDENTIALS secret in GitHub:\n\nWe'll use the Azure CLI once more:\n\nRemember to replace the {subscription-id} with your subscription id and {resource-group} with the name of your resource group (rg-aca if you're following along). This command will pump out a lump of JSON that looks something like this:\n\nTake this and save it as the AZURE_CREDENTIALS secret in Azure.\n\nRunning it\n\nWhen the GitHub Action has been run you'll find that Azure Container App is now showing up inside the Azure Portal:\n\nYou'll see a URL is displayed, when you go that URL you'll find the hello world image is running!",
"title": "Azure Container Apps, Bicep and GitHub Actions"
}