Host ASP.NET Core - Web API (RESTful) In Azure App Service

This blog will show you how you can host a RESTful ASP.NET Core Web API in an Azure App Service.

Prerequisites

  • Visual Studio
  • Azure Account
 In this demo, I have already created a project. You can download it from GitHub.

Open the project in Visual Studio.

Web API (RESTful) in Azure App Service

Right-click on the project solution and select "Publish" from the opened menu.

Web API (RESTful) in Azure App Service

Now, make sure your account is logged-in in Visual Studio. The "Pick a publish target" blade will appear; select the "App Service" tab.

I am starting it so I have selected "Create New" radio button. Now, let us click the "Advanced" label.
It will pop one more window for the advanced settings. Once you've selected the desired settings, click the "Save and Publish" button.
 
Web API (RESTful) in Azure App Service

Set your App Service name, Resource Group, and Hosting Plan. Application Insights is recommended for production build.

Web API (RESTful) in Azure App Service

I have already created a database using SQL Server. So, right now, skip creating a SQL Database method.

Web API (RESTful) in Azure App Service

Once the "Create" button is clicked, it will start to deploy the information view in the output window. My app service has completed successfully. You can see the site URL info on the above.

Web API (RESTful) in Azure App Service

Oops! When I try to look onto my URL, it seems to show HTTP Error 500.0.

Web API (RESTful) in Azure App Service

To clear the issue, we need to add the web.config file to this project.

Web API (RESTful) in Azure App Service

Add the above XML code in web.config and publish your app again.

Web API (RESTful) in Azure App Service

Now, the RESTful API Web Service is ready to use. Currently, I am using SwaggerUI in my project.

Let’s look at the App Service inside an Azure portal.

Web API (RESTful) in Azure App Service

We can monitor the App Service usage, request, and response time.

Web API (RESTful) in Azure App Service