<img alt="" src="https://secure.leadforensics.com/150446.png " style="display:none;">

Azure DevOps to build the CI/CD pipeline

Surbhi Agarwal May 16, 2019

Azure DevOps CI/CD pipeline

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.

magento2-docker-1

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

magento2-docker2

magento2-docker-3

  • 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.

magento2-docker-4

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

magento2-docker-5

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

Similar Blog

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.