Working With Azure API Apps


Working with Azure API APPS

 

Introduction

According to Microsoft –“API apps in Azure App Service offer features that make it easier to develop, host, and consume APIs in the cloud and on-premises. With API apps you get enterprise grade security, simple access control, hybrid connectivity, automatic SDK generation, and seamless integration with Logic Apps

In simpler words, it is a platform for hosting the Web Apis with most common API features as out of the box service for which you don’t have to code.

We can directly host the application in a web app and leverage all the above services but there are 4 main reasons that I personally think API Apps serves better than Web App

  • Inbuilt Swagger Integration

  • Ability to push your API APPS into Azure MarketPlace.

  • API Definition

  • Support for creating an Azure API Client from Visual Studio.

 

We are going to create a demo and discuss all the 4 main reasons along with the demo.

 

Create an API From Visual Studio and Host it in Azure API APP

  • Go to Visual Studio -> Visual C# -> Web -> ASP.NET Web Application and Enter the name of the API and click on OK Button.

 

  • Now select Azure API App from the dialog box, We can select Web API as well and then publish it as Azure API App which will also serve the same purpose.

 

 

 ​​​​ 

Inbuilt Swagger Integration

 

  • As we have selected the Azure API App some of the common Web API used packages like Newtonsoft.Json and Swasbuckle.core (Swagger) comes directly in the template.

 

 

 

  • Create an API Controller by right clicking on the controller and Add -> Controller.

 

 

  • Now select the Web API 2 Empty Controller. You can use any of the controller but for this demo we are going to use the empty controller.