How To Enroll IoT Device on Azure Device Provisioning Service Using X.509 Certificate

This article explains how to enroll an IoT device on Azure device provisioning service using X.509 certificate. In my previous articles on the Azure IoT series, we have learned about the Azure IoT Hub and Device Provisioning Service (DPS). If you have not read my previous articles about Azure device provisioning service yet, then please read them using the following link.As explained in the previous articles, IoT devices on the IoT hub can be connected in two ways that are
  • Using Device Provisioning Service then Azure IoT Hub
  • Directly to the Azure IoT hub
So let's learn how to enroll the IoT devices with Device Provisioning Service (DPS).

What is Device Enrollment?

Device enrollment is the process of adding the pre-configured IoT devices details on Azure device provisioning service and connect to the IoT hub on-demand or based on the requirement without any human intervention.

Now let's learn step by step how to enroll the IoT devices

Step 1: Login To Azure Portal

After login into the azure portal, find the device provisioning service which we have created in the How To Create Azure Device Provisioning Service article or if you haven't created it, then please follow the steps shown in the article and create it. I hope you have DPS services on the portal. Now find the option to manage enrollments as shown in the following image.


 Device Provisioning Service (DPS) provide the  following two concepts,
  • Individual Enrollment
  • Group Enrollment
In this article we will learn about the individual device enrollment

What is Individual Enrollment?

This allows enrolling one device at a time that allows unique configuration per device. 

Step 2:  Navigate To Azure Device Provisioning Service Instance

To create the individual enrollment, select manage enrollment, then click on the Add individual enrollment as shown in the following image.


After clicking on the Add individual enrollment button, the following screen will get appeared as shown in the step 3.

Step 3: Provide Enrollment Details and X.509 Certificate

Provide the required details including the X.509 security certificate


As shown in the preceding image, we need some details to create the enrollment entry,
  • Attestation Mechanism
  • Primary Certificate
  • Secondary certificate
  • IoT Hub Device Id
  • IoT Edge Device
  • Device Allocation Policy
  • Choose IoT Hub
  • Device Re-Provisioning
  • Device Twin State
  • Enable Entry
These details differ based on the chosen attestation mechanism type as shown in the following image

What is Attestation Mechanism?

The attestation Mechanism is the process of cross verifying the enrolled device identity during the device registration on IoT Hub, Device Provisioning Service supports the following attestation mechanism

  • X.509
  • TPM
  • SymetricKey
Now let's learn how to enroll devices using the above attestation mechanisms

Device Enrollment Using X.509

The X.509 is the security certificate which includes the authentication details about the device. These certificates can be provided by a device manufacturer which they can buy from the authorized certificate provider such as CA. For development and testing purposes we can create the X.509 certificate by using the tools like PowerShell or OpenSSl etc. I will show in a separate article how to generate the X.509 certificates.

I have X.509 certificates on my pc which I have generated using the PowerShell


Now choose X.509 attestation mechanism from the dropdown list and choose the device.cer certificate as shown in the following image.


After uploading the certificate provide the following optional details

IoT Hub Device Id

Provide the Device Id name which is unique per X.509 certificate. This is optional, if you do not provide the device Id, then the registration id becomes the deviceId on the Azure IoT hub.

IoT Edge Device


Choose between true or false, which indicates if it's true, then it's an edge device, else it's an IoT device.

Device Allocation Policy

This chosen policy decides how IoT devices allocate to the IoT Hub, you can read my previous article to understand the details about the device allocation policies.

Choose IoT Hub

Device provisioning service can be linked with multiple IoT Hubs, you can choose on which IoT hub, device should register or you can let it decide by device allocation policy.

Device Re-Provisioning Policy

There may be a requirement to re-provision the device, so during this process, it allows whether to keep the previous data or not.

Initial Device Twin State

The initial device twin allows storing the custom properties about the device or whatever you want. Mostly, the device twin is used to keep the device-related information such as the path of the device upgrade package file or client details etc.

Example,


{  
  "tags": {},  
  "properties": {  
    "desired": {  
      "devicetype": "waterflow",  
      "client": "www.compilemode.com"  
    }  
  }  
}  

Enable Entry

This option allows enabling to disable the enrollment entry.

Now providing all the above details, click on the save. After successfully creating the enrollment entry, the following notification will be shown.


Now go to our created device provisioning service (DPS) instance and see the created enrollment entry as follows.



In the preceding image, you see the registration id as my device which comes from the certificate common name (CN).

Device Enrollment Using Symmetric Key

Now choose the symmetric key attestation mechanism from the dropdown list and check on auto-generated keys as shown in the following image.



Provide the required details as we did in the X.509 enrollment, in the symmetric key attestation mechanism we need to provide the registration id but in X.509 enrollment the registration id taken from the certificate common name (CN).

Now providing all the above details, click on the save, now go to our created device provisioning service (DPS) instance and see the created enrollment entry as follows.


As shown in the preceding image, we see the registration id reg100 is added, follow the same steps for other types of attestation mechanism, and enroll the device.

Summary

I hope this article is useful to understand how to enroll the device using azure device provisioning service with X.509 certificate.

Introduction To Azure IoT Hub

In my last article, we learned about the Azure device provisioning service, which allows us to manage IoT devices. If you have not read my previous article about Azure device provisioning service yet, then please read it using the following link
Now we have a platform to manage the IoT devices, but what about connecting the devices to some platform and getting the data from those connected devices? We must connect the device to some gateway platform to establish a secure connection between the cloud and the device to exchange the data. So, in this article we will learn about the Azure IoT hub and the role of IoT Hub in managing the IoT devices communication and telemetry data.

What is Azure IoT?

Azure IoT is the IoT gateway for IoT devices which allows bi-directional communication between IoT devices to cloud and cloud to IoT devices. Azure IoT can process the millions of IoT devices and route the messages to specific data storage platforms.

Key Advantages of Azure IoT

  • Built-in UI to manage and monitor the IoT devices
  • Allows us to capture entire device lifecycle events using the device life cycle change event feature
  • Allows us to upgrade the firmware of single or bulk of devices using the automatic device management feature
  • Allows the bi-directional communication between IoT devices to cloud and cloud to IoT devices
  • IoT hub allows us to connect the edge devices and IoT devices its means IoT hub capable to connect low powered and high processing devices
  • IoT devices can send telemetry data as well as can connect devices over a network using AMQP, MQTT, and HTTPS protocol to the Azure IoT hub
  • Azure IoT hub supports the wide range of IoT device authentication mechanisms such as X509, TPM, and Symmetric Key
  • Azure IoT hub allows routing the messages to the specific data store and data process platform using the message routing feature
  • Azure IoT hub allows uploading the file for a specific device which can be used for device upgradation for storing device process-related information
  • Azure IoT hub IoT Hub allows us to send commands to the device which can help to change the behavior of the device using the Cloud to Device message feature
  • Provides the device twin feature to store the metadata or any specific information about the IoT devices
  • Azure IoT hub is supposed to be a secure platform for communication and authentication for the devices with the help of communication protocol AMQP, MQTT and HTTPS and authentication mechanisms such as X509, TPM, and symmetric key
  • Provides the wide range of SDK which help to connect to the IoT hub and devices programmatically C#, java, python, C, Node.js, android SDK also IoT hub supports api
  • Provides the feature to enable or disable the connected IoT devices

Creating An Azure IoT Hub Using Azure Portal

Azure IoT Hub can be created using:
  • Azure CLI
  • SDK
  • API
  • ARM
  • Azure portal 
In this article, we will be creating an IoT hub using the portal so we can avoid confusion for beginners. Now let’s start creating the azure IoT hub step-by-step via the Azure portal.

Prerequisites
 
To create any Azure service, we need an active Azure subscription, whether it’s a paid or trial subscription. I am assuming you have an active Azure subscription

Step 1: Go to the Azure Portal

Navigate to the portal.azure.com using your browser and login into the portal with valid credentials, as shown in the following image:


After a successful login, the page will be redirected to the Azure portal, by default, the dashboard page is set as:


Step 2: Create Azure IoT

Find the create resource option which can be found on the left top side of the portal as shown in the following image or follow any other option which you may know to create the resource (service) in the Azure portal:



Click on the left side option to create a resource & type IoT hub into the populated search box, it will pop up the following screen as:



As shown in the preceding image click on the create button, it will show the following screen:



Provide required details as shown in the preceding image:
  • Subscription: Choose the available azure subscription which you want to use for creating service from drop-down list
  • Resource Group: Choose an existing resource group or create a new resource group that you may want to use.
  • Region: Choose the deployment location for IoT hub device provisioning from the given list. However, the device provisioning service is global and associated with any specific location, but you must specify a location for the resource group where the metadata associated with the service profile will reside.
  • IoT Hub Name: Name of the IoT hub service which must contain only alphanumeric characters or a hyphen.
After providing all the basic required details, click to review and create the IoT hub, which skips the remaining steps, or click to choose the next step, networking. It shows the following screen to configure networking:



In the above image, we choose the connectivity method for the IoT hub which decides which network the devices can connect to the IoT hub, there are three methods:
  • Public Endpoint all Network
  • Public Endpoint selected IP addresses
  • Private Endpoint 

Public EndPoint all Network

This option allows us to connect devices to the IoT hub on all public networks for whoever has access to public URI and the required credentials.

Public Endpoint selected IP addresses

Even you have a public endpoint (URI) but want to restrict devices, you should connect from a specific IP address. Then you can define the range of IP addresses. The IoT hub allows you to connect only to devices that fall within the defined IP address range. This option gives the useful feature to allow only known networks to connect to the devices

Private EndPoint 

This is the URI or endpoint which allows us to connect devices over the private network, which gives the robust security between devices and IoT hub communication
Once you choose your intended connectivity method, click on the next step which shows the step to configure the scalability of the IoT hub as:


The preceding management step allows us to define the scalability and security of the IoT hub with the help of the following options:
  • Pricing and Scale Tier
  • IoT Hub Units
  • Defender
Pricing and Scale Tier
 
There are different types of pricing and scale tiers that decide how many messages the device sends to the IoT hub per day and what feature does it supports. The features and message frequency of IoT hub can differ based on the pricing and scale tier. The pricing tiers are categorized as:

Free Tier
 
The F1 is the free tier by using you can use the free tier of IoT hub for your learning and check how IoT hub works. it allows 8000 messages per day with limited feature

Basic Tier

The basic tier is sub-categorized into the three types as
  • B1
  • B2
  • B3
Basic tiers are suitable for development activities but you can not get all the features in this pricing and scale tier.

Standard Tier

The standard pricing and scale tier provides the most advanced features and scales for the incoming IoT messages, The standard tier subcategorized into the three types as:
  • S1
  • S2
  • S3 
These tiers are most suitable for a production environment where hyper scalability and advanced security are required. Once you choose the configuration for the IoT hub, click on the next step tags, which shows the following screen:



The tagging helps to identify or categorize the services across the line of applications, after providing tags details, click on the next step review and create, it will show the following screen to review the details before creating the service:


After reviewing details, click on the create button, it will take some time to create the service. Once the service is created, the status can be notified on the notification icon as shown in the following image: 


Now click on the Go to resource button, you will be redirected to the newly created IoT hub service as shown in the following image:


Let’s learn about the preceding Azure IoT hub key sections in brief, listed below:
  • Overview
  • Certificates
  • Built-in Endpoints
  • Query Explorer
  • IoT Devices
  • Automatic Device Management
  • Messaging
  • Security
  • Monitoring
Overview
 
The overview section of the IoT hub is like a dashboard where you can see an overview of the service details, including the charts for incoming messages, status, etc.

Certificates
 
This section allows to add and save the device certificates which can be assigned to the devices during creating or adding the devices to the IoT hub.

Built-in Endpoints
 
This section contains the details which allow us to use the IoT hub as an event hub. The event hub compatible connectionString gives almost the same functionality as an event hub without creating any instance of the event hub.

Query Explorer
 
This section allows us to query devices that reside in the IoT hub. This feature is useful to query any device from the millions of devices from the IoT hub.

IoT Devices
 
This section lets you add the different types of IoT devices and related configuration.

Automatic Device Management
 
This section allows us to upgrade the firmware of individual or bulk of IoT devices based on the properties of the device such as tags or deviceId.

Messaging
 
This feature allows to capture the IoT device messages and their related events also you can route the messages to any other service such as data store etc.

Security
 
This section allows to secure the IoT devices using the IoT defender feature and create the security-related alerts

Monitoring

This section allows to monitor the logs related to the IoT hub, you can set any filter or rule for monitoring and create the alerts

Summary

I hope this article was useful for understanding the basics of the Azure IoT hub service.

Next Suggested Article
Articles you may interested 

How To Host ASP.NET MVC Web Application on Local IIS

In my previous articles we have learned how to create an ASP.NET MVC application and how to publish an ASP.NET MVC application. Now in this article we will learn how to host an ASP.NET MVC application on IIS . Hosting is required to make any application accessible to the end-user publicly on the web. So, in this article, we will learn how to host ASP.NET MVC application in IIS 10. The following steps are required to host any application.
If you don't know how to create, develop and publish  an ASP.NET MVC application then please refer to following step by step tutorial.
I hope you have learned required steps that is developing and publishing ASP.NET MVC application, Now lets start hosting MVC application on IIS.

Move the published code on Hosting Server

Copy the "Published files" which we have seen in our previous article Publishing an ASP.NET MVC Application Using File System and paste those on respective servers where you want to host the ASP.NET MVC application. In our last article we have published code in the E drive of my server, as shown in the following image .



Open IIS Manager

Now, open the IIS Manager from Windows menu or in any other ways you have known.

 

The above image is of IIS 10 Manager of my Windows 10 machine. The view as well as options might be different on your machine depending on the OS version.

Add Website to host an ASP.NET MVC application

Right click on "Site" in IIS and click on add new website, as shown in the following screenshot.


After clicking on "Add Website" option, it displays the following configuration window.


I hope you understood the preceding configuration by highlighted text.

Define Site Name & Application Pool

Define the site name which will be useful to uniquely identify the site within the IIS server. After specifying the site name, choose the application pool from available pools. You can even create a custom application pool with any desired name. Currently, our IIS manager has the following application Pools.

 

Choose the application pool depending on your application configuration. In this article, we are going to choose DefaultAppPool.

Browse and select Published Folder path

Now, choose the physical location of published code files by clicking on "Browse" button, as shown in the following image.


Now, click on "OK" button.

Define IP address & Port

Choose one IP address from the list of available IP addresses and define the unique port number for the application, which will be unique within the defined IP address.

Choose Protocol & Host name (optional )

Choose the protocol for your application i.e HTTP or HTTPS which requires port 443 to be open and choose the Host name which will be used publicly to access the application. After defining all the configurations, the web site configuration window will look like this.


Now, click on OK button. It will create and add the application in IIS.

Browse the application using web browser

Browse the hosted application using your system (PC/Laptop) browser , Click on browse hyperlink which is highlighted in the following image

 

After clicking on preceding IIS shown image browse hyperlink, then application will open in your default web browser as shown in the following image
 
 

Preceding is our IIS hosted ASP.NET MVC application which is running in browser.

Note
  • This article is just guideline to show how to host ASP.NET MVC web API application on IIS .
  • Optimize the speed by setting debug as false etc., from web.config file as per your skills.
  • In this article, the optimization is not covered in depth.
  • Configure the authentication in IIS as per your requirement . 

Summary

I hope, this article is useful for all the readers to learn about hosting an  ASP.NET MVC web application on local IIS. If you have any suggestions, please contact me.

Learn How to Create an ASP.NET MVC Application Step by Step

Running ASP.NET Core Web Application in Docker Container

In this article we will learn how to run an ASP.NET core web application in a docker container. The intend to write this article is to clear the hype around docker and make understandable to everyone by explaining in the simple and plain language.

What is Docker?

Docker is the platform for deploying and building the applications which delivers the application in the packages over the operating system level virtualization. Docker requires the following components to run the application

  • Image 
  • Container

What is docker image?

Docker image is the set of configuration and instructions to create the docker container, an image is created during building the application based on steps defined in the docker file of your application. The docker image is the read-only file which cannot be modified once it's created, but we can delete the image from docker.

What is Container?

The Container is an independent isolated process of an operating system which has its own networking and file system to run the image or application. The container is created on the docker engine based on the image configuration.

Difference between Virtual Machine and Docker Container?

The virtual machine (Linux, ubuntu) is installed on some other operating system (windows) which shares the same lifecycle such as running and shutting at the same time. Virtual machine acts as a real PC on an actual operating system which has full features such as RAM, Hard Disk, networking etc. In this case, often virtual machines are called guest PC and the actual PC which runs the VM is called host system machine.
The container is the minimal and smaller part of a virtual machine which does not use the entire operating system as a virtual machine. The container cuts the unnecessary components of the VM and creates the isolated virtualized environment called a container, which is faster than virtual machine. The container does not require the host system as a virtual machine instead, it works on the docker engine.


The preceding diagram gives more understanding about the virtual machine and docker container.

Step 1: Install Prerequisites

You need to install the docker desktop client based on your machine (PC) as per your operating system type. Use the following link to download the docker desktop client.
The installed docker desktop client looks like as follows.


I hope you installed the prerequisites.

Step 2 : Create the ASP.NET Core Application

  1. Open Visual Studio (I am using 2019)
  2. Once Visual studio open then click on Continue Without Code(If you are using VS 2019)
  3. Then from Visual Studio Menu, click on File => New Project , as shown in the following image

After clicking on the New Project, following window will get appears, Choose the project template ASP.NET Core Web App as shown in the following image


After Choosing the project template click on next button, provide the project name and storage location of the project on your PC


After providing the required details, click on next button the following screen will get appears. Provide the additional information for your project such as target framework and other details, Just choose the latest .NET 5.0 and skip other details

 
Now providing the required details, click on create button it will create the ASP.NET Core web application and created ASP.NET Core web application looks like as follows in your visual studio.

Step 3: Add Docker Support

Docker support can be enabled in two ways from visual studio, at the time of creating the application and after creating the application. To make it easier to make understand for beginners, in this tutorial we will enable the docker support after creating the ASP.NET core application.

Right click on the solution explorer of your existing project and follow the steps which are shown in the following image.


Once you click on the Docker Support option, it will prompt the screen which is shown in the step 4.

Step 4: Choose the Container (Docker File)

Choose the target operating system on which type of container you want to run the application, and it will create the docker image. Let's choose the Linux option which creates the image size smaller than compared to the windows container image.


In the preceding image click on the OK button, it will create the Docker file in your project solution as shown in the following image.


Step 5: Open the Docker File

Double click on docker file in which you will see auto generated code from visual studio which has pre-configured steps to create and run the docker image in multiple stages.

The visual studio creates docker file in your project which has multi-stages build features which make sure the final image remain smaller in the size which helps to become container more efficient and faster. The container images created in the following stages
  • Base 
  • Build 
  • Publish
  • Final Image

We will learn more about the base image and docker file stages in a separate article.

Step 6:  Run the image in Docker Container

Choose the docker option to run the application as shown in the following image.


After clicking on the docker option, it will build the code and creates a docker image as well as a docker container and run the application inside the docker container. The application opens in the browser as follows.


In the preceding, our application is running inside the Linux Docker container instead of IIS express. We can view the created images by using the docker command or navigating to the docker desktop dashboard. Let's view images using the docker command. Open your windows command prompt and use the following command on the command prompt and press enter.

           Docker Images

The preceding docker command will display the list of available docker images as follows.


I hope from all the above-mentioned examples you have learned how to run the ASp.NET Core web application inside the docker container.

Note

  • This tutorial is for the beginner, so there is no command line tool used to build, run the docker container images but internally after clicking on Visual Studio Run Option by choosing Docker option does the same thing
  • The intend of this tutorial is to make familiar to beginners about docker.
  • Next article we will learn how to build, run and create images using docker commands.

Summary

I hope the preceding article is useful to understand how to run an ASP.NET core web application in a docker container.

Related articles

How To Delete Records From Azure SQL Table

In this article we will learn how to delete the records from the Azure SQL table using step by step, so beginners and students can also understand.

Prerequisites

If you are new to the Azure SQL, then please watch my following videos on the Azure SQL database.

How To Create Azure SQL Database

How To Connect Azure SQL Database

Let us consider we have the Employee table in our Azure SQL Server database having the following records,


The following two commands are used to delete the records from the Azure SQL table.

  • Delete
  • Truncate

Using Delete Command

The delete command is used to delete all the records from the table or specific records by using the Where clause.

What does Delete Command Do?

  • The Delete command can be used with or without a WHERE clause.
  • The Delete command removes all records if you use it without the where condition.
  • The Delete command removes the one or more rows based on the condition given in the Where clause.
  • The Delete command maintains the logs of each deleted record. This helps to keep track of each deleted record.
  • The Delete command activates triggers. It means you can take certain action whenever you delete the record, such as inserting the deleted records in some other table etc.
  • The Delete can be rolled back. It means that if the records are deleted by mistake, then we can restore the deleted record back to the table.
  • The Delete command does not reset the identity of the table. It means that when you delete all the records from the table having Id between 1 and 10, then after adding the new record in the table, it will start with the ID count from 11, not 1.

Deleting Specific Records

To delete the specific record from the table, we need to use the where clause.

Syntax

delete from TableName where ColumName=value

Example

delete from Employee where Id=1

The above query will delete the records from the Employee table which has id 1. After deleting the record, then the table records will look like as follows.

Deleting all records

To delete all records from the table, we need to write a query without the where clause.

Example

delete from Employee

The above query will delete all records from the Employee table.

Using Truncate command

The truncate command removes all the rows from a table.

What does Truncate Command Do?

  • Truncate removes all rows from a table, but the table structure such as columns, constraints, indexes remains. 
  • Truncate command can not be used with where or any condition.
  • Truncate command can not be activates the trigger, It means we can not take any action on deleted records.
  • Truncate cannot be rolled back, it means deleted records from the table cannot be restored.
  • Truncate resets the identity of the table, it means that when you delete all the records from the table having Id between 1 and 10, then after adding the new record in the table, it will start with the ID count from 1, not 11.
  • Truncate command can not be maintains the logs of deleted record. It means we can not keep the track of each deleted record.
Example

truncate table Employee

The preceding query deletes all the records from the table.

Summary

I hope this article helped to know how to delete records from the Azure SQL database. If you have a suggestion related to the article, then please comment using the comment box.

Azure SQL Alter Table Statement

In this article we will learn about the Azure SQL alter statement. In the previous article we have learned how create and connect to the Azure SQL database. If you are new to the Azure SQL, then please watch my following videos on the Azure SQL database.

How To Create Azure SQL DataBase

How To Connect Azure SQL DataBase Using SQL Management Studio


What is SQL Alter Table Statement?

Alter statement used to modify the structure of the existing table. The alter statement used is to add, drop the table column. It can also be used to change the data types of the column etc.
Let us consider we have the table having name Employee in our Azure SQL Server database having the following records,



Add Column To Existing Table Using Alter Statement

The following SQL query will add the new column Salary into the existing table.

ALTER TABLE Employee
ADD salary  decimal(50);

You can alter the multiple columns at a time, the following query will alter the multiple columns of the existing table.

ALTER TABLE Employee ADD
(
Location varchar (50),
EmailID Varchar (50)
)

Modify The Existing Table Column
You can rename or change the data type of the column using the alter statement.
Example
ALTER TABLE Employee 
MODIFY Salary  decimal(60);

The preceding query will change the Salary column data type size to 60 from previous 50.
Drop The Column of Existing Table

ALTER TABLE Employee
DROP COLUMN Salary;

The preceding SQL query will remove the Salary column from the existing Employee table.
Summary
I hope from all the above demonstration, you have learned about the Azure SQL Alter statement and its uses of the Alter statement.

Related Article

How to Create ASP.NET Core Web Application

In this article we will learn how to create a step by step ASP.NET Core web application with razor pages. Prior to going the particle part let's know about the ASP.NET Core.

What is ASP.NET Core?

ASP.NET Core is an open source cross platform framework for developing and building web, cloud, IoT applications.

Why should we use ASP.NET Core?

  • ASP.NET is an open source platform which runs on Microsoft .NET Core Framework.
  • We can build and run the ASP.NET core application on a cross platform environment such as Windows, MacOs, Linux etc.
  • We can build modern apps such as Cloud, IoT, Web apps, mobile backend etc. and those can be easily enabled to run over the cloud platform.
  • We can host application on any modern platform such docker, AKS etc.
  • Saves the efforts of the developer by built-in features such as dependency injection, you can enable docker, containerization, swagger support in just one click.
Now let's start creating ASP.NET Core web application.

Step 1: Open Visual Studio

  • Open Visual Studio ( I am using 2019)
  • Once the Visual Studio Opens, Then click on Continue Without Code as shown in the following image

  • Then from Visual Studio Menu, click on File => New Project, as shown in the following image


Click on the New Project, then the following window appears as shown in the step 2.

Step 2: Choose Project Template

You will see the two project templates,
  • ASP.NET Core Web App: This project template creates the web application with Razor pages without Model, View, Controller.
  • ASP.NET Core Web App (Model-View-Controller): This project template creates the web application with Model, View, Controller (MVC).
Choose the ASP.NET Core Web App Template as shown in the following image.


After choosing the project template click on Next.

Step 3: Define Project Name and Location

In the project configuration window you will see the following options,

Project Name: Define the any name for your project as per your choice.
Location: Choose the location to save the project files on your hard drive of the machine. I have chosen the Project/VS folder of the E drive of the machine, and obviously it's different on your computer.
Solution Name: Solution name is auto-defined based on the project name, but you can change the name based on your own choice. 

Additionally, there is a checkbox, if you have checked it, then the solution file (.sln) and project files will be saved in the same folder. Now Choose the minimum details for ease of understanding as shown in the following image.


After defining the required details, click on the Next.

Step 4: Choose the Target Framework

Choose the target framework  .NET 5 which is the latest or you can choose based on your requirement, skip the other details for ease of understanding as shown in the following image.


After providing the required details, click the create button. It will create the ASP.NET Core web application with razor pages as shown in the following image.


The preceding is the project structure of the ASP.NET Core web application.

Step 5: Run the ASP.NET Core Application

You can run the application with default contents or let open the Index.cshtml file and put some contents there. Now press F5 on the Keyboard or use the run option from Visual Studio to run the application in the browser. After running the application, it will show in the browser as shown in the following image.


I hope from the preceding step by step demonstration, you have learned how to create the ASP.NET Core Web Application with Razor view.

Summary

I hope this article is useful to understand how to create ASP.NET core web application. In the next article we will learn how to perform the CRUD operation in ASp.NET Core.

Related Tutorial

www.CodeNirvana.in

Protected by Copyscape Online Copyright Protection
Copyright © Compilemode