Deploy Azure container Instances using Azure DevOps CI/CD pipelines

In this article we are going to deploy our angular application to Azure Container instance using CI/CD pipelines from azure DevOps and Azure Container registry
First we should push our application toAzure Repos so don’t forget to use the below git commands
git remote add origin repo-address
git push -u origin — all
Azure Devops CI Pipline
Now we will start with the first step which is create our CI pipeline we will require two tasks: the first one is related to the angular project which is the npm install task and the second one is related docker task and it will be in charge for building and pushing our image to Azure registry
So first, we must connect to our Azure registry. In the settings, navigate to service connection New service connection.

Then we choose Docker Registry Service

Next step is to setup the connection to our Azure container registry

Let’s take look to our docker file before we push our image to the registry;
# base imageFROM node:12.2.0# set working directoryWORKDIR /app# add `/app/node_modules/.bin` to $PATHENV PATH /app/node_modules/.bin:$PATH# install and cache app dependenciesCOPY package.json /app/package.jsonRUN npm installRUN npm install -g @angular/cli@7.3.9# add appCOPY . /app# start appCMD ng serve --host 0.0.0.0
Now will create our pipeline, we have choose ubuntu as an agent;

Now we setup the npm install Task as show on the sceenshoot

Next let add the docker task for build and push images

you should specify the container registry, the container repository, the command and the docker file then save and queue
Azure Devops CD Pipline
After we’ve finished pushing our image to the azure container registry, we will use the Release Pipelines to deploy it to an azure container instances.
Once we create our release pipeline, we should choose the artifact as source of the deployment.

Next we have to add the stages; in our case, there is only one stage with one task which is the azure CLI Task, this task responsible for creating an Azure container instance .

we will choose PowerShell as a script type and we will write our commands on the script inline.
az container create -g aci-demo --name aci-demo-app --image $(acrLoginServer)/demo-aci:11 --cpu 1 --memory 1 --registry-login-server $(acrLoginServer) --registry-username $(acrName) --registry-password $(acrPassword) --ports 80
don’t forget to add your azure container registry login credentials in variables section.