Creating an API on Azure

One of the most common infrastructure components, when dealing with a mobile app, is to have an API. An API will provide information to your mobile app, while communicating with your local database or resources. Think of the API as an intermediate between your mobile app and your server based resources, providing a single point of access. Having an API has many benefits, such as allowing you to limit API usage to those that have authenticated, provide rate limits, control access to a database through a single access point and easily monitoring usage.

Create WebAPI

First, here is a quick example of how to create a WebAPI in Visual Studio with C#. Create a new Project and select ASP.NET Core Web Application.

Then select WebAPI, and press OK, unless you want to use one of the default authentication mechanisms. If so, press Change Authentication to select your provider.

Now that you have your API, you can publish it. You have two options on how to do this. The first we will look at, is creating an Azure API App in Azure first.

 

Create API App in Azure

Search for API in the Azure Portal.

And create a new API app.

Sometimes you may prefer to create it directly in Azure first, to ensure everything is set correctly. The Azure Portal gives you more information and control of the setup, than the second method of creating directly from Visual Studio.

Publish API to Azure

Open up your WebAPI project, right click on the project and press publish.

Once done, this screen will appear. Press Create New or Select Existing, depending on if you have set it up on Azure yet or not.

Follow the wizard and it will then upload your API to Azure and load the API in a web browser once finished. You just need to click Publish each time you want to update your API on Azure. The previous upload settings will be saved.

If you want to add a domain to your API, go back into the Azure portal and click on your Azure API, then Custom Domains, to add one in. Look at Map a custom domain to an Azure App for more detailed information.

Authentication

Authentication to your API, is the last crucial step. You have the option of using a 3rd party to manage your accounts, or do it your self. Have a look at these options to decide which might be best for your needs.

Microsoft MVP (Xamarin) | Exrin | Xamarin Forms Developer | Melbourne, Australia

Related Posts

Leave A Comment?