In this article, we will not only learn about hosting Angular applications on Azure but we will also see how we can implement CI/CD using Azure DevOps.
To do all these, we would require an Angular application. So, for that, I have just created a new Angular application using Angular-CLI for demo purposes.
Before starting, let us briefly look at what CI and CD mean.

Continuous Integration (CI)

This is a software development practice in which all developers merge their code changes in a central repository multiple times a day. With CI, each change in code triggers an automated build-and-test sequence for the given project, providing feedback to the developer(s) who made the change.

Continuous Delivery (CD)

Here, every change that passes all stages of production pipeline is released to the customers. There's no human intervention here. Developers can focus on building software, and their work goes live minutes after they've finished working on it.
On top of Continuous Integration, Continuous Delivery will add the practice of automating the entire software release process. Continuous Delivery includes deployment, which may be manual and may consist of multiple stages. What’s important is that all these processes are fully automated.
A CI/CD pipeline helps you automate steps in your software delivery process, such as initiating code builds, running automated tests, and deploying to a staging or production environment. Automated pipelines remove manual errors, provide standardized development feedback loops and enable fast product iterations.
(source: https://semaphoreci.com/blog/cicd-pipeline)
Okay, so let’s start working on it.

Hosting on Azure

At first, we will host our Angular application on the Azure platform. To do so, we need to sign in to the Azure account here.
After signing in, we are going to create the Resource. For this, navigate to the App Services tab on the left pane.
Hosting Angular Application On Azure With CI/CD
Now, inside this, we will create our first App Service. For this, press the Add button and it will redirect us to create a Web App.
  1. Here, there is an option for Subscription. I have selected my subscription to Visual Studio by default.
  2. There is also an option for Resource Group. This Resource Group is used if you are managing N number of clients and you require grouping the resources according to your clients. To do so, create a new resource group with some name. In our case, I am having a group named ‘jinalshah’.
  3. Next is Instance Details. Inside this, Name is where you can enter your application name. This is your web app Name. This name would act as a Sub-Domain. Here, I am giving a name as ‘angulardeploydemo’. Now, your whole URL will be ‘angulardeploydemo.azurewebsites.net’.
  4. Now select a Runtime Stack. Here I am selecting ASP.NET v4.7.
  5. Next, select your Operating System to Windows OS.
  6. Next, select the Region which is nearest to your location. Here I am selecting Central India as a Region.
  7. Moving forward to the App Service Plan Section. Here select your Linux/Windows Plan and then select the Sku and Size. By clicking on this Sku and size, you are able to see different plans with their facilities available on the Azure Platform. You can select the plan based on your requirements. I am selecting the Free plan (F1) having Shared Infrastructure from the Dev / Test tab.

    Hosting Angular Application On Azure With CI/CD

  8. Finally, you can press the Review and create a button and it will create your first App Resource.
So, the entire screen will look like this.
Hosting Angular Application On Azure With CI/CD
And now, you can see the Summary as per this next screen and then click on the "Create" button. This will deploy your server and create it on the Azure platform.
Hosting Angular Application On Azure With CI/CD
Hosting Angular Application On Azure With CI/CD
So when deployment gets completed, you are able to see the below screen.
Hosting Angular Application On Azure With CI/CD
And now, click on the All Resources tab from the left pane and you can see the resource that we created.
Hosting Angular Application On Azure With CI/CD
Hosting Angular Application On Azure With CI/CD
Now, if we click on the ‘angulardeploydemo’ of the type App Service (2nd from the above list), we can see all the resources allocated to our app service. On this screen, check the URL (top-right corner).
Hosting Angular Application On Azure With CI/CD
By clicking on this URL, you can see it will show us Home Page (by default) of Azure. So, this way, you can host your application on the Azure Platform.
Hosting Angular Application On Azure With CI/CD

Implement CI/CD

It’s time to publish our actual Angular application on this Azure Platform and also to implement CI/CD with GitHub (or any source control) for our Angular application.
For this, we need to set Azure DevOps and Pipelines to perform CI/CD.
    • Select your Git Repository’s Branch in Branch Specification.

      Hosting Angular Application On Azure With CI/CD

    • Now press on the Save & Queue button. And this will ask you for some information. In this window insert some Comment and then press Save and Run.

      Hosting Angular Application On Azure With CI/CD

      Now it will perform (run) all those tasks which we have created in Agent. So it will first install Node.js then it will install the Angular-CLI. Then it will add all the dependencies and will create the Production Build. Then it will finally host the App on Azure App Service.

      When all the Tasks of Agent get completed successfully then you are able to see the below screen.

      Hosting Angular Application On Azure With CI/CD
Hooray...!!! Your Angular Application is Live on Azure Server..!!
Hosting Angular Application On Azure With CI/CD
Note that we have not just Hosted the App to Azure but we have also implemented CI.
So let’s examine the working of CI/CD,
This will take some time to finally reflect the changes on the server.
So by implementing this CI/CD, all our changes of the Angular Application can directly go live whenever we push the code on Github.
You can always check on Azure Platform if you are having anything new in your Pipeline or not. You can check in Pipelines tab on Azure Platform as below,
Hosting Angular Application On Azure With CI/CD
Finally, you can Refresh your browser and you can see the new changes done using CI/CD.
Hosting Angular Application On Azure With CI/CD
Thank you for reading this article.!