In this lab you will deploy Azure Container Apps, Azure Database for PostgreSQL, and other Azure Services (Key Vault, Storage and Managed Identity) with Azure CLI and Bicep.
You will deploy containers from GitHub Container Registry and built with GitHub Actions.
You will also import and have the opportunity to explore data from the Cassini mission to Saturn, thanks to Rob Conery (@robconery)'s A curious moon/SQL in Orbit.
- 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
The link below will deploy Azure Container Apps, Azure Database for Postgres and Key Vault via a single ARM template, generated from main.bicep. This template will also create a Resource Group for you.
Use the Azure CLI and Bicep templates to deploy the infrastructure for your application.
This allows you to deploy the Bicep templates of your choice step-by-step.
Login to the Azure CLI.
az login
Set environment variables and create a Resource Group.
RESOURCE_GROUP="my-container-apps"
LOCATION="canadacentral"
az group create \
--name $RESOURCE_GROUP \
--location "$LOCATION"
Change directory to this directory, cloud-native/containerapps-bicep
.
cd cloud-native/containerapps-bicep
Deploy the bicep templates of your choice with the following az deployment
commands.
# containerapp
az deployment group create \
--resource-group "$RESOURCE_GROUP" \
--template-file ./containerapp.bicep \
--parameters \
location="$LOCATION"
# storage
az deployment group create \
--resource-group "$RESOURCE_GROUP" \
--template-file ./storage.bicep
# postgres + keyvault (combined)
az deployment group create \
--resource-group "$RESOURCE_GROUP" \
--template-file ./postgres-keyvault.bicep
# key vault (stand-alone)
az deployment group create \
--resource-group "$RESOURCE_GROUP" \
--template-file ./keyvault.bicep
# postgres (stand-alone)
az deployment group create \
--resource-group "$RESOURCE_GROUP" \
--template-file ./postgres.bicep
# empty
az deployment group create \
--mode Complete \
--resource-group "$RESOURCE_GROUP" \
--template-file ./empty.bicep
The template used in the Deploy via Azure Portal section above can also be deployed via the CLI. Note this is a subscription-scoped deployment and it will create the Resource Group for you.
# subscription (containerapp + postgres-keyvault)
LOCATION='canadacentral'
az deployment sub create \
--name='220600-containerapps' \
--location $LOCATION \
--template-file ./main.bicep \
--parameters \
resourceGroup='220600-containerapps'
See POSTGRES.md for instructions on how to login to your Postgres server from your local machine.
Once you have finished exploring, you should delete the resource group to avoid any further charges.
az group delete \
--name $RESOURCE_GROUP