Azure App Deployment With GitHub Action

In this article, you will learn how to build and deploy an application on the Azure app service using GitHub Actions. We will create Azure App Service, App Service Plan, upload the code on Github and deploy the code through the GitHub actions to app service.

App Service is a service that hosts applications like web apps, logic apps, APIs, etc. To create an app under the app service, you need an azure app service plan. So let’s first create one azure app service plan.

App Service and Plan

  • Log in to the Azure portal using your credentials.
  • In the search box, search the text “App service plans” and click on the first option.

Azure App Deployment with GitHub Action

  • It will open a new window “Create App Service Plan”. Fill in the required fields and click review and Create.
  • Once it’s created, go to the newly created resource. You will see your service plan under App Service Plans. Refer to the below image.

Azure App Deployment with GitHub Action

  • Now it’s time to create App Service. In the search box, type the text “App Services” and select the first option.

Azure App Deployment with GitHub Action

  • Under the App Service, click on the create button.
  • Fill in the required details. Select the App service plan that you created in the previous steps and hit review and Create.

Azure App Deployment with GitHub Action

Almost everything is done from the App service side. Let’s create one Web API that we will deploy/host on Azure App.

Web API .Net Core

  • Open the visual studio 2019 or visual studio code.
  • Create a new project “Asp.Net Core Web API”.
  • In this demo, I will be using my existing code that is already available on my GitHub Repository AnujAngooral GitHub

There are two different ways to create a pipeline on GitHub, either from Azure or from GitHub directly.

I will be showing you through the Azure portal.

Azure Deployment Center

  • Open the Azure App Service and from the left panel select “Deployment Center”.
  • Under the Settings, select the source “GitHub”.
  • Log in to GitHub.
  • Select the organization from the dropdown, in my case, it’s AnujAngooral
  • Select the Repository that you want to deploy on the app service.
  • In the Branch dropdown, select the one on which you want to trigger the event and push the changes on the Azure portal.
  • Once everything is done, hit Save

Azure App Deployment with GitHub Action

GitHub Action

  • Go back to Github and select the repository for which you have configured the Azure app service.
  • Click on the Actions tab.
  • You will see a workflow has been configured for this repository.

Azure App Deployment with GitHub Action

  • Click on the workflow to see the stages or the flow of the workflow.
  • Once you open the workflow, you see two stages build and deploy.
  • When you push the changes into your master/main branch (in my case main), it will first build the code and if everything goes as expected, then it will deploy the build on the Azure.

Azure App Deployment with GitHub Action

  • The green ticks refer to stage completion.

Run Azure Web Site

  • Log in to the Azure portal.
  • Go to the App service folder.
  • At the top, you will see the browse button. Click on it.
  • Your site is up and running.

Azure App Deployment with GitHub Action

Similar Articles