close
close

Deploying a web application with CI/CD pipeline on Azure App Service.

Deploying a web application with CI/CD pipeline on Azure App Service.

Deploying a web application with a CI/CD pipeline on Azure App Service involves several steps, from creating the web application to configuring the CI/CD pipeline. Here is a step-by-step guide:

Prerequisites

  • Azure Account: Make sure you have an active Azure subscription.

  • Source code repository: Your web application source code should reside in a Git repository (e.g. GitHub, Azure Repos, Bitbucket).

  • Visual Studio Code: Install VSC for command-line operations.

  • CI/CD Tool: You can use tools like GitHub Actions, Azure Pipelines, or any other CI/CD service.

Create an Azure Application Service
Log in to the Azure portal:

Create the web application plan:

  • In the Azure portal, search for “App Services Plan” and click “Create”.

Image Description

Image Description

  • Create or select an existing resource group

  • Give a name to the application service plan

  • Select operating system and region

Image Description

Image Description

  • Click “Review + Create” and then “Create”.

Image Description

Image Description

Create the web application:

  • In the Azure portal, search for “App Services” and click “Create”.

Image Description

Image Description

  • Select the resource group created earlier.

  • Provide a name for the application service, which will be the domain name (.azurewebsites.net).

Image Description

  • Choose a runtime stack (e.g. .NET, Node.js, Python).

  • Select region and rate plan.

Image Description

  • Click “Review + Create” and then “Create”.

Image Description

Image Description

Image Description

Configure the CI/CD pipeline

Using GitHub Actions:

Connect Azure App Service to GitHub:

  • Navigate to your application service in the Azure portal.

  • In the left menu, select “Deployment Center”.

Image Description

  • Under “Source”, select “GitHub”.

  • Authenticate with your GitHub account.

Image Description

Image Description

Image Description

  • Choose the repository and branch you want to deploy.

Image Description

Set up your local development environment:

  • Initialize Git from the Visual Studio Code terminal:

Image Description

Image Description

Image Description

Image Description

Image Description

Image Description

  • Press the file with index.php

Image Description

  • Nano in file using nano index.php

Image Description

  • let’s use a simple expression

echo “Hello world” which is an output

Image Description

Image Description

  • Read the output of the file using the following commands

add .

then git commit

Image Description

Then push

Image Description

Result

Image Description

Click Browse to read the result

Image Description

Change the exit message and press again

Image Description

Image Description

Image Description

Image Description

Image Description

Conclusion
You now have a web application deployed to Azure App Service with a CI/CD pipeline configured. This configuration ensures that every time you push code changes, your web application is automatically tested and deployed, ensuring faster and more reliable updates.