Deploying the ASP.NET Core application in Azure

Let's create an ASP.NET Core application that we can deploy in Microsoft Azure:

Deploying the ASP.NET Core application in Azure

The ASP.NET Core application will be created once you click the OK button:

Deploying the ASP.NET Core application in Azure

As the default ASP.NET Core Web Application template uses the Entity Framework, we need to execute the following command in order to create the database migration:

dotnet ef database update

Once you enter the command in Command Prompt (in the project's path), the migration file will be created. This migration file will contain all the changes to the database. This migration will be applied at the time of deployment at Azure so that Azure can create the necessary database scripts for Azure deployment:

Deploying the ASP.NET Core application in Azure

Once the database migration is completed, right-click on the created Core application and select the Publish option, as shown in the following screenshot:

Deploying the ASP.NET Core application in Azure

When you click the Publish option, you'll be shown the following screen, depicting various publishing options available for you:

Deploying the ASP.NET Core application in Azure

Please select the Microsoft Azure App Service option to publish the web application on the Microsoft Azure platform:

Deploying the ASP.NET Core application in Azure

Click on the New button, and you will get the following screen:

Deploying the ASP.NET Core application in Azure

You can change the web app name to whatever name you would like to have. I have changed the web app name to learningmvc6.

Click on the New button beside the Resource Group and enter the name for the resource group. The resource group is just a tag where you can group all of your computing resources so that if you want to delete all the resources, you can just delete the resource group. For example, a resource group could comprise of a web server and a database server—you can think of it like a collection of resources.

Now, click on the New button beside the App Service Plan. You will get the following window where you can choose the location and size of your web application container. Your location could be anywhere from South Central US to Europe, from Japan to Canada. Your application container could be anything from free to a machine with 7 GB RAM. I have chosen the free option as our objective is to deploy the ASP.NET Core application in a cloud environment rather than to deploy an application which is to be accessed by millions of users. Of course, you can achieve the same with ASP.NET Core and Microsoft Azure:

Deploying the ASP.NET Core application in Azure

Now, we can configure the SQL database which is available as an additional Azure service.

Deploying the ASP.NET Core application in Azure

Click on the + button which is available at the top section which will lead us to the configuration of the SQL database.

Deploying the ASP.NET Core application in Azure

If you have any existing SQL server in the Azure environment, you can use it. As I don't have any such server, I am going to create a SQL server by clicking the New button beside SQL Server:

Deploying the ASP.NET Core application in Azure

Please enter the administrator user name and password for the SQL Server and click OK. You will see the following screen:

Deploying the ASP.NET Core application in Azure

Once you click OK, you will get the following screen:

Deploying the ASP.NET Core application in Azure

Click OK on the preceding screen and we will see the Create App Service screen:

Deploying the ASP.NET Core application in Azure

Click Create once we have configured all the required Azure services:

Deploying the ASP.NET Core application in Azure

The preceding screen shows the deployment configuration options, such as the Site name and Destination URL for our application. Click Next on the preceding screen:

Deploying the ASP.NET Core application in Azure

It is important to note that you need to expand the Databases option and Entity Framework Migrations options and select both the checkboxes. The first checkbox represents the connection string that should be used at runtime and the second checkbox represents the database migration that should be applied on publication.

Deploying the ASP.NET Core application in Azure

The preceding screen is the preview screen where you can see the files that would be deployed when you publish. This is an optional step—if you want to see the files, you can click the Start Preview button. Or else, you can click the Publish button to publish the web application in the Azure platform.

Once you click the Publish button, our ASP.NET Core application will be deployed in Azure and your application URL will be opened on successful publication. You will get the following screen:

Deploying the ASP.NET Core application in Azure

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset