Building and deploying a .NET Core app to Azure

Overview

In this tutorial, we will learn how to build and deploy a .NET Core application to Azure. We will start by creating a new .NET Core web application using Visual Studio. Next, we will configure the application for Azure and create an Azure App Service. Finally, we will publish our application to Azure.

Prerequisites

To follow this tutorial, you will need the following:

  • Visual Studio 2017 or later
  • Azure account with an active subscription
  • .NET Core SDK installed on your machine

Step 1: Create a new .NET Core web application

Open Visual Studio and create a new .NET Core web application. For this tutorial, we will create a basic web application using the ASP.NET Core Web Application template.

  1. Open Visual Studio and select “Create a new project”.
  2. Select “ASP.NET Core Web Application” from the list of templates.
  3. Choose a project name and location and click create.
  4. In the next window, select the “Web Application” template and click create.

Visual Studio New Project

Step 2: Configure Azure for the application

In this step, we will configure Azure for our application. First, we need to create a new App Service in Azure. Once this is done, we will configure the application for Azure.

  1. Log in to your Azure portal and select “Create a resource”.
  2. Search for “App Service” and select “App Service” from the list of results.
  3. Choose a name for your App Service and select a subscription, resource group and app service plan.
  4. Click “Create” to create your App Service.

Azure Create App Service

Once your App Service is created, navigate to the “Deployment Center” tab. Select “Visual Studio” as the source and click “Continue”.

Azure Deployment Center

In the “Visual Studio” tab, download the publishing profile for your App Service.

Azure Download Publishing Profile

Next, go back to Visual Studio and right-click on your project in the Solution Explorer. Select “Publish” from the context menu.

Visual Studio Publish

In the “Publish” dialog, select “Import Profile” and select the .publishsettings file you downloaded from Azure. Once the profile is imported, click “Next”.

Visual Studio Import Profile

In the “Connection” tab, select the target App Service and click “Validate Connection”. If the connection is successful, click “Next”.

Visual Studio Connection

In the “Settings” tab, choose the deployment mode and click “Publish”. Your application will now be published to Azure.

Visual Studio Settings

Step 3: Publish the application to Azure

In this step, we will publish the application to Azure.

  1. Right-click on your project in the Solution Explorer and select “Publish”.
  2. Select “Microsoft Azure App Service” as the target.
  3. Select your App Service and click “Create Profile”.
  4. Verify the connection and click “Publish”.

Visual Studio Publish App Service

Your application will now be compiled and published to Azure. Once the deployment is complete, navigate to your App Service in the Azure portal and select the “Browse” option to view your application.

Conclusion

In this tutorial, we learned how to create a .NET Core web application and deploy it to Azure. We created a new App Service in Azure and configured our application for Azure. Finally, we published our application to Azure using Visual Studio. With this knowledge, you can now deploy your own .NET Core applications to Azure with confidence.

Related Post