Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Deploying a Node.js API and Mysql Docker images to Multicontainer app in Azure App Services through CI/CD

Overview

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:

  1. Build a custom Docker image.

  2. Push and store the Docker images in a private repository.

  3. Deploy and run the images on Azure App Services.

Setting up the Environment

  1. The following resources needs to be configured for this lab:

    • Azure Container Registry

    • Azure Web App for Containers

  2. Create Azure Container Registry:

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

      ACR

    Note:- Enter a unique ACR name. ACR name may contain alpha numeric characters only and must be between 5 and 50 characters.

    1. Click Create.

      ACR

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

      ACR

  3. Create Azure Web App for Containers:

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

      ACR

    Note:- Enter a unique Azure Web App Name.

    1. Select Docker Compose (Preview) Option, Image Source, Registry and click Review+create.

      ACR

    2. Click Create.

      ACR

Exercise 1: Configure Continuous Integration (CI)

Now that the required resources are provisioned, the Build and the Release Pipelines needs to created.

  1. Navigate to the Azure DevOps and select the Competence evenings project.

    SelectProject

  2. Select Repos and click import to import a new repository.

    Tasks

  3. Select Repository type as Git and enter the Clone URL as https://github.com/srinathreddy4/regent-tech-demo. Select Import.

    Tasks

  4. Select Library under the Pipelines.

    Tasks

  5. Select +variable group to create a new variable group.

    Tasks

  6. Enter the variable group name and below variables. Click on the Save button.

    Tasks

  7. Select Project settings at the bottom left.

    Tasks

  8. Select Service Connections and select New service connection.

    Tasks

  9. Select Docker Registry.

    Tasks

  10. Enter the details which you noted down earlier and click save.

    Tasks

  11. select pipelines and click New pipeline to create a Build pipeline.

    Tasks

  12. select Azure repos Git.

    Tasks

  13. select regent-tech-demo repo.

    Tasks

  14. select Existing Azure Pipelines YAML file.

    Tasks

  15. select master branch and yaml file path. Click Continue.

    Tasks

  16. Click Run to run the Build Pipeline.

    Tasks

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

    Tasks

Exercise 2: Configure Continuous Delivery (CD)

  1. Select Releases under the Pipelines and click New pipeline to create a Release Pipeline.

    Tasks

  2. Click + Add to add the artifacts from the build pipeline. Select the Project and Source.

    Tasks

  3. Select Variables and Variable groups to link the variable group created in the previous Exercise 1.

    Tasks

  4. Select Tasks and click Run on Agent to configure the Job by slecting Agent Pool and Agent Specification.

    Tasks

  5. Click + and select Replace Tokens task. Configure the task as shown in the below image.

    Tasks

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

    Tasks

  7. Select Create release and click Create to run the pipeline.

    Tasks

  8. The Release will deploy the application on Azure web App for Containers. Once the build is completed, the build summary will be displayed.

    Tasks

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

    Tasks

Testing the API

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

Summary

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.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages