Tip
Be sure to checkout my blog post on this which provides a comprehensive deep dive, insights, and step by step guide here.
Note
Microsoft have announced Managed DevOps Pools coming soon which will make this process a lot more seamless, you can read more here
This repository will enable and showcase how you can deploy a fully private Azure DevOps self hosted agent on an Azure Container Instance, pulled from a fully private Azure Container Registry and deploy to an App Service behind a Private Endpoint.
The repo includes all the necessary components to deploy the Azure resources, Azure DevOps pipeline, .NET App.
This repository lab aims to help showcase and cut time from others who have difficulty achieving this solution due to the nature of limitations presented by a fully private Azure Container Registry with no public access. It will be applicable to any image to an ACI resource.
Initial deployment will create an ACI with a placeholder docker image pulled from a public source to facilitate a successful ACI deployment which further allows the manual ACR task run.
Once the private ACR image is built from your own private dockerfile then a redeployment following the steps will allow the ACI to pull the new image from the private ACR that is entirely private to your organisation vs public docker image.
- Azure DevOps Project
- Azure subscription to deploy into
- Azure DevOps Service Connection (workload federation identity strongly recommended) that has
contributor
access to your Azure subscription - Familiar with GIT
It's advised to read the blog for further information but here is a quick deployment flow tldr;
- Clone this repo to your private Azure DevOps git repository
- Create a PAT with
Code: Read
&Agent Pools: Read & Manage
permission scopes - Create a new pipeline using an existing YAML file and select the
deploy-app.yaml
file, amending the variables for your ARM connection name - Add the relevant config details under the ADO Agent parameters in
main.bicepparam
- Deploy the Azure resources
az deployment sub create -l uksouth -n deploy -f main.bicep -p main.bicepparam -p AZP_TOKEN=YOUR_ADO_PAT
-
Add a comment to the
Dockerfile
file to trigger the acrBuildTask -
Uncomment lines 45 to 51 in the
aci.bicep
module file and save -
Amend the
aciImage
parameter in themain.bicepparam
file to from'mcr.microsoft.com/azuredocs/aci-helloworld:latest'
to'${acrName}.azurecr.io/ado-agent:latest'
-
Redeploy the Bicep template again using the commands from step 5 to pull the private ACR image into the ACI
-
Lastly, trigger the App Deploy pipeline in ADO to deploy the web app using the private agent
Note
Feel free to fork this repo and customise the Bicep code as you see fit if you feel comfortable doing so. I have hard-coded some values for simplicity of the demo (e.g. repository name / tag).