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.
- Open Visual Studio and select “Create a new project”.
- Select “ASP.NET Core Web Application” from the list of templates.
- Choose a project name and location and click create.
- In the next window, select the “Web Application” template and click create.
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.
- Log in to your Azure portal and select “Create a resource”.
- Search for “App Service” and select “App Service” from the list of results.
- Choose a name for your App Service and select a subscription, resource group and app service plan.
- Click “Create” to create your App Service.
Once your App Service is created, navigate to the “Deployment Center” tab. Select “Visual Studio” as the source and click “Continue”.
In the “Visual Studio” tab, download the publishing profile for your App Service.
Next, go back to Visual Studio and right-click on your project in the Solution Explorer. Select “Publish” from the context menu.
In the “Publish” dialog, select “Import Profile” and select the .publishsettings file you downloaded from Azure. Once the profile is imported, click “Next”.
In the “Connection” tab, select the target App Service and click “Validate Connection”. If the connection is successful, click “Next”.
In the “Settings” tab, choose the deployment mode and click “Publish”. Your application will now be published to Azure.
Step 3: Publish the application to Azure
In this step, we will publish the application to Azure.
- Right-click on your project in the Solution Explorer and select “Publish”.
- Select “Microsoft Azure App Service” as the target.
- Select your App Service and click “Create Profile”.
- Verify the connection and click “Publish”.
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.