e-Zest members share technology ideas to foster digital transformation.

Azure DevOps to build the CI/CD pipeline

Written by Surbhi Agarwal | May 16, 2019 2:15:19 PM

The purpose of this blog is to give you an overview of Azure DevOps and how it can be used to build the CI/CD pipeline (Visual Studio Team Services).

Azure DevOps is a very strong hosted service which provides development and collaboration tools. There are many services available which can be used to build the CI/CD pipeline. It makes work simple and understandable. It provides free tier to get started and we don’t need our own agents to start with like Git repositories for source control, build and release pipeline for CI/CD automation and many more.

It provides a lot of inbuilt features and functionalities that allows teams to get up and running with managing their project and automate their workflows to increase productivity.

First of all, you should have an account on VSTS. Create a new project and get started.

Now, let's have a look at how to deploy a Nginx image to Web app through the VSTS.

We have Azure Web App for containers which help to deploy container-based web apps. We can pull images from Azure Container Registry (ACR) and Docker Hub and then deploy the containerized app with required dependencies.

First Step: Configuring CI pipeline to build and publish Docker image

  • Go to Azure Portal
  • Create ACR (Azure Container Registry), Web App for Container
  • In Azure DevOps portal, first, create a repo save entrypoint.sh file and Docker file in it
  • I have deployed Ngnix and PHP in my image
  • Docker File

FROM ubuntu
# Upgrade and Install Nginx
RUN apt-get update && apt-get install -y \
Nginx \
vim \
software-properties-common
# Autostart Services
COPY ./ Docker-entrypoint.sh /usr/local/bin
RUN chmod a+x /usr/local/bin/ Docker-entrypoint.sh

# Nginx configuration
COPY ./ Nginx/default /etc/ Nginx/sites-available/default
COPY ./ Nginx/default /etc/ Nginx/sites-enabled/default

# expose the port 80
EXPOSE 80
ENTRYPOINT ["entrypoint.sh"]

  • Entrypoint File

# Run Nginx
Nginx -g "daemon off;"

  • Push these files in repos with the help of Git in the local.
  • Now, In Azure DevOps portal, select Builds from Pipelines. Select Docker option you will get Build an image and Push an image option in this and then click Edit.

  • Fill the details of your Azure Subscription, Azure Container Registry details and Web App details and save it.

  • Remember to select and include the latest Tag option so that it will always take the latest build and build the image with it and then push it to ACR.

Step Second: Deploying to an Azure Web App for container

  • As we have already created the Web App for Container, you need to check some key settings in it.
  • Go to Application setting, in General setting always keep On tab as On.
  • Then, go to Container settings, fill the details of Azure Container Registry with a tag as the latest and save it once.
  • Now give the Build by selecting a Queue option.

  • When the build will be successful, and you hit browse option in Web app you will see the image of Nginx running.

Hope this article helped in knowing Azure DevOps and how it can be used to build the CI/CD pipeline (Visual Studio Team Services).