In this lab you will create a sample Go app from a template repository in GitHub. You will then use the included GitHub Actions workflow which will build a container image you can then make public. You will then deploy the public container image to Azure Container Apps.
Azure Container Apps enables you to run microservices and containerized applications on a serverless platform. With Container Apps, you enjoy the benefits of running containers while leaving behind the concerns of manually configuring cloud infrastructure and complex container orchestrators.
- An Azure Subscription (e.g. Free or Student account)
- The Azure CLI
- Bash shell (e.g. macOS, Linux, Windows Subsystem for Linux (WSL), Multipass, Azure Cloud Shell, GitHub Codespaces, etc)
- A GitHub Account
- Visit https://github.com/asw101/go-hello
- Click "Use this template".
- Name your repo "serverless-gopher".
- Create a new branch called release.
- Click on the Actions tab.
- View the output of the action.
- Return to the main repo (Code tab).
- Click on "serverless-gopher" under "Packages" on the right hand size.
- Copy the
docker pull
command which will include the image name. - Update the
GITHUB_USER_OR_ORG
environment variable below with your GitHub username or organization name. - Note: If you chose to make your GitHub repository Private rather than Public in step 3, you will need to click on "Package settings" on the right hand side, scroll down and click "Change visibility" button to make your package public.
If this is the first time you have used Azure Container Apps from the Azure CLI, or with your Azure Account, you will need to install the containerapp
extension, and register the providers for Microsoft.App
and Microsoft.OperationalInsights
using the following commands.
az extension add --name containerapp
az provider register --namespace Microsoft.App --wait
az provider register --namespace Microsoft.OperationalInsights --wait
RESOURCE_GROUP="my-container-apps"
LOCATION="canadacentral"
CONTAINERAPPS_ENVIRONMENT="my-environment"
GITHUB_USER_OR_ORG="asw101"
CONTAINER_IMAGE="ghcr.io/${GITHUB_USER_OR_ORG}/serverless-gopher:release"
az group create \
--name $RESOURCE_GROUP \
--location $LOCATION
Quickstart (docs.microsoft.com)
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--location $LOCATION
az containerapp create \
--name my-container-app \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT \
--image "$CONTAINER_IMAGE" \
--target-port 80 \
--ingress 'external'
CONTAINERAPP_FQDN=$(az containerapp show --resource-group $RESOURCE_GROUP \
--name my-container-app \
--query properties.configuration.ingress.fqdn \
--out tsv)
echo "https://${CONTAINERAPP_FQDN}"
curl "https://${CONTAINERAPP_FQDN}"
az group delete \
--name $RESOURCE_GROUP