Deploy ASP.NET Core Web Applications to Azure in 5 Easy Steps
In one of my previous
articles I discussed how easy it is to deploy an ASP.NET Core web
application to IIS. Now a days more and more people are going for cloud
platforms for their ting needs. So, it would be worthwhile to know how to deploy
an ASP.NET Core web application to Azure. To that end this article outlines the
basic steps to accomplish the task.
I am going to assume that you have an Azure account and have successfully
logged-in to Azure Portal. So, let's begin.
1. Create Azure resource group
First we will create what is called a Resource Group in Azure. Simply put, a
resource group is a logical collection of resources belonging to an application.
Resource groups allow you manage your resources more easily. To create a
resource group, click on the Resource groups option on the left side.
This will take you to the following screen where you need to click on Add
option. If you have created resource groups already, they will also be listed
here. If you want to use an existing resource group you can skip this step and
pick the existing RG in next step.
When you click on the Add option, a screen will be shown that allows you to
specify the resource group name and location.
Now that your resource group is ready, you can go ahead and create an Azure
2. Create Azure Web App
To create an Azure website, click on the Create a resource option from the
left side. This will open a screen as shown below:
Here, select Web App option to go to the following screen:
Specify web app's name and pick the resource group created earlier. Note that
the app name needs to be unique and it becomes part of your web app's URL. For
example, if you name your app as MyWebApp then the URL will be
Specify these details and click on Create button to create the web app. It
might take some time for this task to finish.
Once successfully completed, the newly created web app will appear in the
resource group as shown below:
At this point if you try to navigate to your web app's URL you will see this:
3. Create ASP.NET Core application
Now, create a new ASP.NET Core Web Application based on the MVC template as
you normally do.
Create the web application as per your requirement.
4. Publish web application to Azure
Once you finish developing the web application, click on the Build > Publish
menu option in Visual Studio.
In the wizard that follows, pick App Service as the publish target and click
on the Select Existing radio button.
On the next screen, you will need to add an Azure account (the same account
that you used to create the Azure web app). Upon adding an account, you will see
the Azure web app you created earlier. Pick the one where you want to deploy
your ASP.NET Core web application.
Be patient as the wizard completes and deploys your ASP.NET Core web
application to Azure.
5. Run the newly deployed ASP.NET Core web application
You just deployed an ASP.NET Core web application to Azure. Open the browser
and hit the URL of the Azure web app.
If all goes well, you should see the landing page of your web application.
That's it for now! Keep coding!!