This repository includes the code for my Container Apps demo at Edinburgh Azure User Group meetup #23 (27th September).
The talk covers deploying Container Apps using bicep, as well as creating a self-hosted Azure DevOps build agent that can be autoscaled based on the queue length of the given agent pool.
-
Start by creating a resource group for all resources to reside in:
az group create -n <RG_NAME> -l <LOCATION>
-
Create the container registry (ensure you are in
/deploy
directory), providing any parameters required:az deployment group create -g <RG_NAME> --template-file .\container-registry.bicep
-
Create the log analytics workspace:
az deployment group create -g <RG_NAME> --template-file .\log-analytics.bicep
-
Create the Container Apps Environment:
Retrieve
logAnalyticsCustomerId
andlogAnalyticsPrimaryKey
from previous output and add tocontainer-app-env-parameters.json
az deployment group create -g <RG_NAME> --template-file .\container-app-env.bicep --parameters container-app-env-parameters.json
-
Build and deploy Azure DevOps self-hosted docker agent to Container registry:
cd ../ado-agent
Build image:
docker build -t ado-agent:latest .
Tag/Push to ACR:
docker tag ado-agent:latest <ACR_LOGIN_SERVER>/ado-agent:latest az acr login -n <ACR_NAME> docker push <ACR_LOGIN_SERVER>/ado-agent:latest
-
Create Azure DevOps Agent Pool:
- Navigate to Organization Settings > Agent pools > Add pool in Azure DevOps
- Select
self-hosted
for Pool type - Provide a name for the Agent pool and click Create
- Obtain the
poolId
by selecting the Pool and copying thepoolId
found in the URL, it should look similar tohttps://dev.azure.com/<ORG_NAME>/_settings/agentpools?poolId=<POOL_ID>&view=jobs
-
Create Personal Access Token:
- A Personal Access token is required to read/create new agents dynamically based on autoscale triggers. The following link demonstrates how to create one
- For scope, select Agent Pools Read & manage. This may require you to click show all scopes at the bottom of the current panel.
-
Create the Self-Hosted Agent Container App:
Retrieve
containerAppEnvId
,containerRegistry
andregistryUsername
from previous steps and add toado-agent-container-app-parameters.json
, as well as changingname
,adoUrl
,adoAgentPool
as appropriateaz deployment group create -g <RG_NAME> --template-file .\ado-agent-container-app.bicep --parameters ado-agent-container-app-parameters.json
When prompted, enter
registryPassword
, which can be found from the Container Registry in Azure, andadoToken
, which is the Personal Access Token created in the previous step.