Azure App Service - API Apps

Microsoft Azure app Service API apps offers secure and flexible development, easy deployment including continous delivery, accessing On-Permises data, Web jobs for background processing, high availability and scaling options for any sized RESTful API Applications. Use frameworks and templates to create RESTful APIs in seconds. Azure API apps are well known for automatic OS patching. You can use any tool or an opearting system to develop your RESTful API with .NET, Java, Node.js, PHP or Python.

  • Fastest and easy way to build productivity developement.
  • Provision and deploy fast and consume API.
  • Simple develop, host access control and authentication.
  • Secure platform, which scales automatically with hybrid connectivity.
  • New Developement experience with API features.
  • API definition for the Website host.
  • Swagger metadata, which is integrated with API app.
  • Easy connectivity with all apps.

    Azure

Source - https://docs.microsoft.com/en-us/azure/app-service-api/app-service-api-apps-why-best-platform

Create a Azure API app Service from Azure portal,;login to your credentials and go to New and select Web+Mobile. In featured apps , you may get API app. If it is not there, then click See all options.

Azure

Type API app and select it from the given list.

Azure

Click Create button to create a new API app.

Azure

Give a name to your API app, your default subscription will be selected by default and I have selected an existing resource group for my app.

App Service Plan/Location is your physical resource, where you host your apps. API app associates with one app Service Plan/Location. You can create a new plan for your app by clicking it.

Azure

You have to choose one pricing tier P1 Premium or S1 Standard or B1 basic for your app.

Azure

Application insights contain tools, which can be used to manage your app behavior. After filling all the necessary details, click Create button to create an API app.

Azure

When your app will create under your selected resource group, a notification appears.

Azure

Whenever your app is created, then you can manage your app such as Deployment settings, Settings, app Service plan, deployment tools, API, Monitoring and some common setting related to the app.

Azure

You can manage and see your app by clicking Overview, where would all the details be, which are available for your app.

Azure

Host your app Service to the existing app on Azure

I’m going to create an Azure API app from Visual Studio 2015 and I will publish it to our existing API app. Thus, let’s create a new solution and give it a name.

Azure

Select Azure API app template from the templates.

Azure

Create a model class by right clicking on Models folder in the solution.

Azure

In the class, I have created three properties. 

  1. namespace AzureApiApp.Models  
  2. {  
  3.     public class Cricketer  
  4.     {  
  5.         public int Rank { get; set; }  
  6.         public string Name { get; set; }  
  7.         public string BatingStyle { get; set; }  
  8.     }  
  9. }}   

Let’s add a Web API2 Controller class by right clicking on Controllers folder.

Azure

Give a name to your Controller class.

Azure

Write the code given below into your Controller class, where I’ve returned a list of cricketers. 

  1. using AzureApiApp.Models;  
  2. using System.Collections.Generic;  
  3. using System.Web.Http;  
  4.   
  5. namespace AzureApiApp.Controllers  
  6. {     
  7.     public class CricketersController : ApiController  
  8.     {  
  9.         [HttpGet]  
  10.         public IEnumerable<Cricketer> Get()  
  11.         {  
  12.             return new List<Cricketer>()  
  13.             {  
  14.                 new Cricketer() {  
  15.                         Rank = 1, Name = "A.B r DeVilliers ", BatingStyle="Right Hand Batsman"  
  16.                     },  
  17.   
  18.                     new Cricketer() {  
  19.                         Rank = 2, Name = "Virat Kohali", BatingStyle="Right Hand Batsman"  
  20.                     },  
  21.                     new Cricketer() {  
  22.                         Rank = 3, Name = "David Warner", BatingStyle="Left Hand Batsman"  
  23.                     },  
  24.                     new Cricketer() {  
  25.                         Rank = 4, Name = "Martin Gupti", BatingStyle="Right Hand Batsman"  
  26.                     }  
  27.             };  
  28.         }  
  29.     }  
  30. }   

Now, it’s time to publish our app to Azure. Right click on the solution and select Publish option.

Azure

Select a target to publish your app and click ext.

Azure

Enter your credentials and you’ll get your Azure Subscription along with the list of Resource Group. If you remember, where I have created an API app in the Default-Web-EastAsia. Expand and select app.

Azure

After clicking OK button, a connection will be created. Click Next button.

Azure

I don’t have any database for this app. Continue clicking on to next.

Azure

Finally, click Publish to publish your app on Azure.

Azure

It can take some time to publish it.

Azure

After a successful attempt, your app Service will be created.

Azure

Your app has been published now you can check your Service data by calling your controller in the Browser.

Azure

In this article, we learned about how can we create an Azure API app and publish it on Azure.

Up Next
    Ebook Download
    View all
    Learn
    View all