ASP.NET Core Deployment with GitHub Actions to Azure App Service

Having already configured GitHub Actions for my Angular projects, the next step was to setup my ASP.NET Core Web APIs. I will run through setting up the GitHub action, creating a GitHub secret with the Azure App Service publish profile.

This will follow the same format as my previous post Angular Deployment with GitHub Actions without the run through of the keywords in the yaml file.

Here is the official Azure WebApp Actions page and here is the official asp.net-core-webapp-on-azure.yml example, you’ll find my example is basically the same with a couple of changes to suit my needs.

So here it is… let’s run through the setup below.

This workflow fires on a push to the main branch. There are a few env settings required to setup and a GitHub secret to add.

File Env Settings

  • AZURE_WEBAPP_NAME is the Azure App Service name is the Instance name before the .azurewebsites.net URL.
  • AZURE_WEBAPP_PACKAGE_NAME is the current directory for the published artifact.
  • DOTNET_VERSION your projects .NET version. I’m using version 3.1.100.

Azure App Service

First, head to Azure to get download the publish profile.

Once you’ve logged in, click on your App Service, at the top of the blade you’ll see Get publish profile, click to download.

Open the file in a editor and copy the contents.

Next…

Setting up a GitHub Secret

Now head to your GitHub repo, go to Settings >Secrets and click on New repository secret.

Add the name of AZURE_WEBAPP_PUBLISH_PROFILE and paste the content of the publish profile in the value text area. Click Add secret to save.

Now you’re all set to deploy your ASP.NET Core project when pushing a commit to your repo. 👍

As simple as that, once again, you can configure your GitHub Action to start its workflow on several events, which makes this such a powerful tool.

Happy coding!

Lead Developer. Angular. Node. GraphQL. JavaScript enthusiast.