Build a Continuously Integrated Global Azure Web App

I invite you to read my solution to the A Cloud Guru Azure Pipelines and Continuous Integration challenge Lars Klint's Azure Pipelines and Continuous Integration .

Azure Pipelines and Continuous Integration

This is the diagram Lars Klint included to visualize the challenge:

February-Cloud-Guru-Challenge-diagram.webp

and here is the solution that I implemented in response to this challenge:

devops-cicd-project.png

Goal

The objective of this project was to create a web application that’s scalable and robust, as well as a stable deployment pipeline for the application.

The objective was achieved by designing and building a DevOps CICD Pipeline using Azure DevOps Pipeline, ARM Templates, App Service, Front Door, Blob Storage, Cosmos DB, Functions and Virtual Network services from Azure.

Outcome

In completing this project I was able to gain real-world skills in App Services, Azure Front Door, Cosmos DB, ARM templates, Functions, Azure Pipelines and Azure DevOps Pipeline YAML configuration.

Main Steps

This project was completed in five steps:

  1. Using an ARM template, an Azure App Service was created with the following properties.
    • Integrate an Azure Virtual Network named “ACGVnet” with the App Service.
    • Integrate Azure Front Door with the App Service.
    • Deployment slot named “staging”.
    • Custom auto-scaling with 1–3 instances, defaulting to 1.
    • A scale rule which triggers the scale action at 70% CPU usage.
  2. Using an ARM Template, a Cosmos DB instance was created with the following properties:
    • Geo-Redundancy
    • API type of Core (SQL)
  3. Using an ARM Template, a Storage Account was created with Blob Storage.
  4. A simple PHP web application was created and GitHub was used for source control.
  5. Created two Functions to connect Web App to Blob Storage and Cosmos DB.
  6. Using YAML an Azure DevOps Pipeline was created with the following components:
    • It successfully builds the web application.
    • If built successfully, run the tests using PHPUnit. NOT YET IMPLEMENTED
    • If tests pass, deploy the application to the “staging” deployment slot for the Azure App Service created in step 1. NOT YET IMPLEMENTED

Solution

The final solution is composed of these Azure Services:

Azure Services UsedPurpose
Resource GroupContainer for all Azure Services
App Service PlanDefines a set of compute resources for the App Service to run
App ServicePAAS HTTP-based service for hosting web applications, REST APIs, and mobile back end
App Service (Slot)PAAS Production and other environments
Front DoorCloud CDN with intelligent threat protection
Virtual networkProject requirement
Storage AccountBLOB Storage Container to store JSON, image and audo objects
Application InsightsMonitor Function that writes documents to Cosmos DB
CosmosDBNoSQL Database that contains the JSON formatted User Documents
Function AppFunctions to write JSON documents to Cosmos DB and retrieve JSON documents from Cosmos DB
DevOpsCICD of the PHP Web Application

Resources Created For This Project (does not include Azure DevOps)

cloud-save-rg.png

New Knowledge Acquired

When I began this project in early Feb 2021 I had three AWS certifications (Solutions Architect, Developer and SysOps), but knew very little of Azure. The cloud knowledge I had from AWS was certainly a benefit, but there was lots new to learn. I took several A Cloud Guru courses (Introduction to Azure, AZ-900 Microsoft Azure Fundamentals, Introduction to Azure Resource Manager, Build and Deploy Azure Templates, Introduction to Azure DevOps) to prepare myself to complete this project.

Solution Artifacts

There are two repositories for this project. The first is for the Azure DevOps Pipeline: Azure DevOps CICD Project

The second is for the ARM Templates and Azure Functions: ARM and Functions

Rewards and Lessons Learned

Azure DevOps Pipeline - learning and implementing an Azure DevOps Pipeline was the highlight of this project. Once the pipeline is created it makes it so easy to deploy code, just a push to my Git Hub repository and, poof, like magic, in a few minutes the Web App has been updated. It is easy to prefer this elegant, yet simple, code deployment approach to the manual approach of maintaining my own VM, WebServer, uploading code, putting it in the right location, etc. The obvious next step is to get PHPUnit tests working which will add even more value to the DevOps pipeline.

This Azure document was particularly helpful in setting up my Azure DevOps Pipeline.

Azure DevOps Pipeline deployment permission - Free Tier is no longer available without permission. This was a significant roadblock to the completion of this project. I finally overcame this by opening a Support Case with Azure. Their response said they had waves of people abusing the free parallel jobs to do crypto currency mining so to get free parallel job I needed to send an email to , the email should include the following:

Azure Function CORS - The Function that reads all documents from CosmosDB has a different origin than the Front Door App Service website. Therefore, a CORS permission was added to the Function using the Portal.

Azure Python Functions - if your Azure Function is written in Python then it needs to be deployed using VS Code with the Azure Functions extension.

Test Drive

You can find my creation at Brian's Azure DevOps CICD Project

The website may not function because cloud having a pay as you go fee structure means I will incur costs if I leave the solution up indefinitely. Therefore, with the goal of cost avoidance I will have shutdown most of the cloud resources associated with this project sometime in April 2021.

Conclusions

This is the fourth A Cloud Guru challenge I have completed and I have learned extensively through completing these challenges. Without a doubt, the highlight of this challenge has been learning Azure DevOps Pipelines. It has been a very valuable experience and I encourage anyone who wants to improve their Cloud Architect skills to complete these challenges.

Thanks Lars for this challenge.