How to: Create GitHub Action to deploy Azure Web App within Visual Studio

This new feature was introduced during MS Ignite 2020

During this week, September 22–24, 2020, Microsoft is presenting MS Ignite. This event was totally remote and free and to follow all the news, Ignite launched one eBook that presents this news. Stay tuned!

Among this news, there is a new feature within Visual Studio where now is possible to publish Azure Web App using GitHub Actions. The respective post about this feature was published on devblogs with the title Using GitHub Actions in Visual Studio is as easy as right-click and Publish.

In this post, I will show, step by step, how do you implement this new feature.

  1. Download and install the latest preview version of Visual Studio:

2. Enable Feature GitHub Actions Support in Publish: go to Tools → Options → Environment → Preview Features menu and click on the option to enable feature GitHub Actions Support in Publish:

3. In this example, I created a new project on Visual Studio using ASP.NET Core Web Application with support Web Application (Model-View-Controller)

4. After creating the project, I pushed it on GitHub using a feature that allows connection with my account.

5. Now, my repository is created on GitHub.

6. The next step, it’s necessary to create an infrastructure on Azure that will receive this new app. To do this, I create a simple Windows App Service using a configuration bellow:

7. After the infrastructure setup, it’s time to publish an application using GitHub Actions. To do this, click on Publish on your Visual Studio project:

8. At Target, select Azure and click on Next:

9. At Specific target, select Azure App Service (Windows) and click on Next:

10. At App Service, select Subscription, View (Resource Group), and in App Service Instances, search for the resource that you created previously and click on Next:

11. At Publish Mode, select Publish automatically using GitHub Actions (generate workflow file) and click on Finish:

12. After this setup, Visual Studio will create a YML file that can edit directly on your solution:

13. Important: Publish setup will connect your respective GitHub account and will create automatically a respective secret:

14. Now, you should create a commit to include the YML file in your repository. This step will start automatically your Actions on GitHub and deploy the application on Azure:

To understand this post, I created a video demonstration that exemplifies this feature:

DevOps Consultant at N3