Introduction
Nowadays, most people are choosing web hosting on a cloud platform. Microsoft lovers like us basically select "Microsoft Azure" as our hosting environment.That’s the reason I have written this new article defining a simple way of hosting in Azure.
Before reading this article, you must read the articles given below for ASP.NET Core knowledge.
Azure Account
First, we need to create an account on the Azure portal. Only then can we host the application in the cloud environment. So, please check the following steps to create an Azure account.
Azure Account Registration
Domain Registration
We need to host our application in a particular domain. Check the following steps -
- Click on "All resources" on the left side menu and it will open a dashboard with an empty or already existing list of resources that we have created earlier.
- Click on the "Add" button and it will open another window with multiple options. We can choose an appropriate option to host our application.
- As per our requirement, we choose "Web + Mobile" and clicked on the "Web App" on the right side.
- It will open another form to fill up our app details to host. We need to give a unique name in the "Appname" section and It will create a subdomain for our ASP.NET Core application.
- We choose subscription as "Free Trial" because we created a free account on the Azure portal.
- We need to host our app resources in Resource group, So first we need to create a resource group name in our Azure account. But we choose existing resource group name "AzureDemo" that we are already created in our Azure account.
- "OS ( Operating System )" we selected as "Windows"( As per our requirement ).
- We can create our own App Service Plan name.
- Application Insight will give you the more clarity about your hosted app. Eg. analytics, etc.
- Click on the “Create” button and wait for the build success.
- Another way to create the Resource Group Name - click on "Resource groups -> Add".
- Once the build is succeeded, then we can see this output.
Simple steps to create an Asp.Net Core Application
- Open our VisualStudio then click on File > New > Project.
- Select Visual C# > Web > ASP.NET Core Web Application.
- We have given our application name as "MyFirstAzureWebApp".
- Then, click OK.
- Click on the "Ctrl+F5".
App Publishing into Azure
We created a default ASP.NET Core application ( We have done some changes in UI Section) for the publishing process.
- Right click on the application and click on the Publish menu.
- Click on the "Microsoft Azure App Service".
- We choose our existing resource group name ( That we created ! "AzureDemo" ) in our Azure Portal and It will display the App Name inside the "AzureDemo" folder. This will display only when we are login through the Visual Studio using Azure credentials ( Email & Password).
OutPut
The application is hosted in a given domain address http://menoth.azurewebsites.net
Reference
See Also
You can download other ASP.NET Core source codes from MSDN Code, using the link, mentioned below.
Summary
We learned how to create and deploy an ASP.NET Core web app in Azure. I hope this article is useful for all ASP.NET Core & Azure beginners.