Deploying a Node.js API and Mysql Docker images to Multicontainer app in Azure App Services through CI/CD
A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
This lab outlines the process to build custom Docker image of a Node.js application, push the image to a private repository in Azure Container Registry (ACR). These images will be used to deploy a multicontainer app in the Azure App Service (Linux) using Azure DevOps.
The Web App for Containers allows the creation of custom Docker container images, easily deploy and then run them on Azure. Combination of Azure DevOps and Azure integration with Docker will enable the following:
-
Build a custom Docker image.
-
Push and store the Docker images in a private repository.
-
Deploy and run the images on Azure App Services.
-
The following resources needs to be configured for this lab:
-
Azure Container Registry
-
Azure Web App for Containers
-
-
Create Azure Container Registry:
-
Select +Create a resource in the Azure Portal and search for Container Registry. Select Subscription, Resource Group, Location, SKU. Replace
<Registry name>with the name of your choosing. Select Review + create.
Note:- Enter a unique ACR name. ACR name may contain alpha numeric characters only and must be between 5 and 50 characters.
-
Click Create.
-
Navigate back to the resource group. Click on the container registry and enable the Admin user for the registry. This is to allow Azure DevOps to push and read images from ACR. Make a note of the Registry name, Login server, username, password. These details will be required in the Exercise 1 and Exercise 2.
-
-
Create Azure Web App for Containers:
-
Select +Create a resource in the Azure Portal and search for Web App for Containers. Select Subscription, Resource Group, Name, Operating System, Region, Pricing Plan. Replace
<Name>with the name of your choosing. Click Next.
Note:- Enter a unique Azure Web App Name.
-
Now that the required resources are provisioned, the Build and the Release Pipelines needs to created.
-
Navigate to the Azure DevOps and select the Competence evenings project.
-
Select Repos and click import to import a new repository.
-
Select Repository type as Git and enter the Clone URL as
https://github.com/srinathreddy4/regent-tech-demo. Select Import. -
Select Library under the Pipelines.
-
Select +variable group to create a new variable group.
-
Enter the variable group name and below variables. Click on the Save button.
-
Select Project settings at the bottom left.
-
Select Service Connections and select New service connection.
-
Select Docker Registry.
-
Enter the details which you noted down earlier and click save.
-
select pipelines and click New pipeline to create a Build pipeline.
-
select Azure repos Git.
-
select regent-tech-demo repo.
-
select Existing Azure Pipelines YAML file.
-
select master branch and yaml file path. Click Continue.
-
Click Run to run the Build Pipeline.
-
The Build will generate and push the docker image of the web application to the Azure Container Registry. Once the build is completed, the build summary will be displayed.
-
Select Releases under the Pipelines and click New pipeline to create a Release Pipeline.
-
Click + Add to add the artifacts from the build pipeline. Select the Project and Source.
-
Select Variables and Variable groups to link the variable group created in the previous Exercise 1.
-
Select Tasks and click Run on Agent to configure the Job by slecting Agent Pool and Agent Specification.
-
Click + and select Replace Tokens task. Configure the task as shown in the below image.
-
Click + and select Azure Web App for Containers task. Configure the task as shown in the below image. Click Save to save the configured pipeline.
-
Select Create release and click Create to run the pipeline.
-
The Release will deploy the application on Azure web App for Containers. Once the build is completed, the build summary will be displayed.
-
Navigate back to the Azure Portal and click on the Overview section of the App Service. Click on the link displayed under the URL field to browse the application and view the changes.
Here are some Postman examples of how to verify our application is working according to specifications. I've compiled a collection for the sake of simplicity: Postman API testing collection
With Azure DevOps and Azure, we have configured a Build and Release pipeline to deploy a Node.js API and Mysql database images on Azure App Services.































