This is the third post in a series on deploying a very simple ASP.NET Core application to the major cloud provides. This post is going to be dealing with setup and deployment to Microsoft Azure.
The following is are the other posts in this series.
This is the same as the first post in the series, but am including it in case you missed that post. The sample application that we will be deploying is the basic Razor Pages applications created using the .NET CLI. The following commands are what I used to create the application, create a solution, and add the project to the solution. I ran all these commands in a
dotnet new razor dotnet new sln dotnet sln add CloudSample.csproj
The rest of this post is going to be based on the official Create an ASP.NET Core web app in Azure documentation. I already have all the Azure related stuff installed and have used it before, so it will be much easier for me to miss a step. If that happens please leave a comment and I will get the post fixed.
Azure Development for Visual Studio
The additional tools need to use Azure from Visual Studio are part of the Visual Studio installer. I’m assuming that Visual Studio is already installed. To add Azure select the Tools > Get Tools and Features menu.
After the installer launches close all instances of Visual Studio. From the list of features select Azure development and click the Modify button to start the installation.
Sign up for Azure
While the tools are installing is a good time to sign up for Azure if you don’t already have an account. You can sign up here. This is one of the parts that doesn’t work well when you already have an account, but the link above should guide you through the process.
Hope back in Visual Studio and open the solution you want to publish. In the Solution Explorer window right-click on the project and select the Publish menu option.
This will show the publish target dialog where you can select what you want to publish to. In this example, we are going to be publishing to an App Service. The details area select Create New option. Then click the Publish button to move to the next screen
The next step collects the information needed to Create an App Service. The first thing to set is the account in the upper right corner of the screen. This could already be set based on how you are logged in to Visual Studio. Next, click the New link next to the Resource Group and enter the name you want to use. Then click the New link next to the Hosting Plan.
In the Hosting Plan dialog, you get options to give the plan a name, pick your hosting location, and the size. For the Size, I recommend starting with the Free option. After all the options are set click OK.
This will return you to the Create App Service dialog where you can click the Create button to deploy the application. After deployment finishes the site will open in your default browser.
For me using Azure from Visual Studio is the simplest experience of all the cloud providers I have tried so far. I don’t guess that is surprising since Microsoft controls both products. Forgetting the integration with Visual Studio it seems that Azure App Services, Google App Engine, and Amazon Elastic Beanstalk are all on par with each other.
As always don’t forget to shutdown/delete the associated resources for your test project to avoid changes.
Also published on Medium.