This article will demonstrate how we can deploy or publish an Asp.Net Core 2.0 application on Azure. As we all know once we create an application we have to deploy it on somewhere it can be IIS, Cloud or somewhere else. Publishing or Deploying an application is a bit difficult task and we get so many issues when we don’t know the exact way how to deploy the application.

So, here I am who will let you each step to publish an core 2.0 on Azure. We have already created an application using Razor Pages, we will use the same application to deploy here.

For more about Razor pages and its fundamentals, See also

  1. Razor page in Asp.Net Core
  2. CRUD operations with Asp.Net Core Razor Pages [We will use this application for deployment]

So, let's jump to practical implementation part. We have a project ready for deployment. To publish an Asp.Net Core 2 application, just right click on the project from Solution Explorer and click to “Publish” option.  We can see clearly that we are using the “RazorPagesExample” application for publishing which we have created in the previous article and this article is using SQL server database and tables for CRUD operations. 

Publish on azure


Once we choose “Publish” option it will open a window where we have different options available to publish an app on Azure or another host like IIS, folder etc. Here we have to choose “Microsoft Azure App Service”  with “Create New” option and without doing anything else just click to “Publish” Option.

Microsoft Azure Service


Next window will show the different option to setup hosting environment and its services.  Under the “Hosting” section, we can define our application name “App Name”, this name will be used to access the application from the browser, define our subscription plan under which we would like to publish an application and resource group for SQL server.

Note: We should have Microsoft Subscription Plan with Azure Credits for deployment.?
Note: If we have a database as a part of application than move to Service Part to create SQL server and database.

 Azure Hosting


As we are publishing an application which is performing CRUD operation, so for that we have required to set up the SQL database as well. So, we will directly move to Services option just below to Hosting to create SQL related services like SQL server, SQL database and connection string etc.

As we can see with below screen inside the Services option we have “SQL Database” with Plus [+] sign inside the Resource Type. To create new SQL service, click on PLUS [+] sign.

Azure sql service


Once we click to PLUS sign button, it will open a popup window which is responsible for setting up SQL server and database.  So, first, we will set up a new SQL Server on Azure. To create new SQL Server on Azure, click to New button as the following screen shown.

Configure Azure SQL Database


From the “Configure SQL Server” window, we have to define SQL Server name, its username and password to access it from SQL Server Management Studio or to use it with Connection String.

Configure Azure Sql Server


After setting up new SQL server and click to OK. It will go back to “Configure SQL Database” screen where we can now set up our SQL database. So here we can define our database name as well as connection string name as we have done with the following screen and click to OK.

Note: Previously it was taking the default database and connection string name. Here we have changed

Confiure Azure SQL database


So, now we have configured three things, first the plan under which our application will publish on Azure. Second one the SQL server where we have configured our SQL database and tables and last one SQL database under the same SQL server as following screen shows.

Azure App Service


Now its time to deploy our application with above configure, so to do that just click to “CREATE” button and it will start deploying our application on Azure as following screen shows.

Deploying on azure


Here we can see that “Azure Successfully Configured” and Visual Studio is going to publish application on Azure. 

Azure Publish


It will take few minutes or seconds as per the network connection and speed and deploy an application on Azure and gives us a message as following which says that App has deployed successfully on the following location.

Publish on Azure


As we all know this application is using SQL database and its tables to perform CRUD operations. We have already created database at the time of configuring SQL services but tables are pending to create. To create required SQL tables under “TestDB” database, to do that we have to access SQL server and its database and manually run the tables scripts.

Now we have to open “Microsoft SQL Server Management Studio” form your system and pass our credentials as we have configured previously for SQL server. Be sure when entering the server name. SQL server name should be in following formats.,1433

Azure login


Oh, we have a new error, which means we are not able to access defined sql server due to firewall rule with this IP address. 

sql error 40615


To resolve this error, we have to add this IP address under firewall rules.  So, open Microsoft Azure portal and select sql server which we have configured previously.

Microsoft Azure Portal


As of following screen shows, under the SQL Server, we have an option “Firewall/Virtual Networks”. Here we can see with the following screen that we don’t have any IP address defined right now. You have to click to “Add Client IP” to add client IP address under firewall rules and click to save it.

Azure SQL Firewall Rules


After adding “Client IP Address”, it will come under the Firewall rules. Now we can access this server from SQL Server Management Studio.

Microsoft Azure Firewall Rules


If we will try once more to log in with SQL Server Management Studio and able to log in. Now select “TestDB” database which we have configured with this publishment and right click and open a new query window. Here we have to run our sql scripts like create a new table, insert new record etc.

Azure Table Creation

So, finally, we have configured everything including database as well. Now its time to access our deployed application. If we access our application with below URL [This is only for my case, you can be defined your own name]. We will see the application as below.

Azure with Razor Page with CRUD operation



So, today we have learned how to publish an application created in Asp.Net Core 2.0 on Azure.

I hope this post will help you. Please put your feedback using comment which helps me to improve myself for next post. If you have any doubts please ask your doubts or query in the comment section and If you like this post, please share it with your friends. Thanks