WHAT IS AZURE?

“Microsoft Azure is an ever-expanding set of cloud services to help your organization meet your business challenges. It’s the freedom to build, manage, and deploy applications on a massive, global network using your favorite tools and frameworks.”

Rather than having to run your own hardware or pay a third party to provide a hardware in a data center, Azure provides access to a massive pool of computing resources that enable you to host web servers, email servers, databases, file storage servers, virtual machines, API management, or anything else you might need.

WHAT ARE WE DOING TODAY?

This tutorial will demonstrate how to deploy and test an APIM (API Management service). Before we begin, you will need to have already created an API Web app and have Visual Studio (I use the Community Edition). For the purposes of this tutorial, one of our developers has created a simple API that we can play with.

Here is a summary of things you need to get started:

  1. Azure Account: You can create an account here: https://azure.microsoft.com/en-us/free/
  2. App Service: You will need to have an App Service running. This is where your API Web app will go live.
  3. Visual Studio: Lets us publish our Web app to an App Services in Azure.
  4. API Web app: The API you want to manage through the APIM.

DEPLOYING AN APIM

Log into your Azure account here: https://azure.microsoft.com/en-us/

  1. Click on “All Services” > Search “API” > Click on “API Management Services” (let’s call it APIM)

2. Click on “Add”

3. Add required APIM information: 

4. It takes 20-30 minutes to deploy an APIM. Tip: Click on “Pin to Dashboard” to quickly find your service.

Once your APIM is deployed, click on it, then follow these steps:

  1. Click on ‘APIs’

2. Click “Add API” to create a new API:

3. Select ‘API App’ (API hosted on App Service):

4. You will be prompted to provide some information.

Things to keep in mind:

  • The information given here is for the APIs hosted on that particular App Service.
  • An APIM can manage multiple APIs from different sources.
  • An APIM uses subscription keys to control who, when, and where the API can be called. You can set a limit on calls and enable the specific endpoint to be cached. Those keys are provided by a ‘Product.’

For example, you have a music streaming service and want to provide an API for developers but you need to control who is approved to use the API and set a limit for the calls. This is where a subscription key comes in handy. Since we need a subscription key to use the API through the APIM, we will select a ‘Product’ and the select ‘Unlimited.’ Now that this particular API is attached to that product, any developer that has a subscription key for ‘Unlimited’ can use this API. Since we are logged in as an Administrator, Azure will by default assign Administrators to the groups that can use the product with ‘Unlimited’ access.

5. Click your newly created API, then click on ‘Add Operation’

6. Here is where we will provide information for our API endpoints:

In the Responses section, select ‘Add response’ and select ’20 OK’ (to let the browser know that the request was processed), and then click ‘Save.’

7. Now we can test the endpoint: Click ‘Test’ > Click ‘Send’

 

USING THE DEVELOPER PORTAL

Now that the API has been built and published, a developer working on the project can go into the Developer Portal and subscribe to the product by clicking on the Developer Portal link in the top right-hand corner. Once a developer signs up, the Azure APIM administrator must assign the product to the developer. Once you have an API Product Key, you can use it to make calls to all the APIs attach to that product.

Let’s go to Azure APIM portal and assign a Developer subscription to the newly created developer account. Then we can test the APIs from the Developer Portal using the assigned key.

TESTING AN APIM

First, sign into the Developer Portal:

Once you sign into the Developer Portal, you can subscribe to a product. The APIM administrator can specify whether the subscription must be authorized. Once you are subscribed to a product, you will receive a subscription key to make calls to every API attach to that product.

One of the features of an APIM is that it enables you to have control of how many times an API can be called during a period of time.

For example, let’s test an API call that has a limit of 5 calls per 60 Seconds. This can be set up in the API inbound call or as a subscription policy.

CONCLUSION

In this tutorial, we explored the process of deploying and testing an API Management service for an ASP.NET Web app. APIM works between the client and the API Web app. We learned how to add APIs to an APIM and endpoints to a particular API list. These are just a few of the wide range of features that Azure API Management Service can provide.