Azure API Management, Azure App Service

How to Get Started with Azure API Management : Part 1

In this post, we are discussing, how to Get Started with Azure API Management, How we can automate API subscription and management using Azure API Management.

This post is a part of the Azure Services series, in this series, we will discuss about Microsoft Cloud Application Architecture and common cloud computing patterns to make application resilient and scalable. We will be using Asp.net MVC as our framework for applicable examples and Azure as cloud services provider.

You can find all the Microsoft Azure Services; we have covered already at Azure series.

How to Get Started with Azure API Management : Part 1

The first question we get in our mind is, why to use Azure API management, what benefits it would give us, and why should we use it.
Azure API Management provide us the ability to create API gateway and developer portal, which is scalable, secure and can work with any host or API and it gives us insights of our APIs as well. The one thing most of us API developers struggle is, how to better manage on boarding process, documentation and provide easiest integration experience to our API’s end users /consumers/developers. This is the part, where Azure API management shines, it give us developer portal to manage the subscription of the services and provides a first-class developer experience. We will discuss all the functionality that Azure API Management provides and how to get most of it.

Let us create our Azure API management Instance first, usually it take a little bit longer around 30 mins to complete creation process.

Go to Azure portal dashboard, click create a new resource button | Search for API management | select API management | click create.

Now we need to fill the form, choose the pricing tier and click create. Let us look at pricing tier first; we have developer, basic, standard and premium tiers.

For Production, either go for basic or high tier since it will give you 99.9+ SLA uptime and options for scalability as well. Every tier support max request per second limitation, if you have only 1 API and 250 subscribers to the service then Basic tier will be sufficient if all 250 users send 2 request per second. From Developer to standard tier, it will only support single region, you can check which region is nearest to your customers/consumers by latency. If you have requirement to support multiple regions, then your only option is to go with Premium tier, and the price per month will increase drastically. Every tier also give us Redis cache as well and capacity is mentioned per instance, if you go for standard tier and you scale it up to 2 instances then you will have 1GB Redis Cache per instance totaling to 2 GB. Other things to consider is AAD integration and virtual network support, if you have need to connect with ADD then go for specific tier after evaluating price to value ratio and also consider virtual network support if you have API service hosted in VM in virtual network then consider it when you make any decision.

For our purpose, we are going with Developer tier, since we are not using it for production and it is giving us almost all the functionalities that other tiers give us except the scaling.

By default, the API management service will have a public URL yourdomain.azure-api.net but we can configure our own custom domain as well.

Creation process will take about 30+ minutes; it took around 38 mins to create in our case. Once the API Management Service is ready, you can see that

Click on developer portal link, will see the screen like below, currently developer/end users can sign up in this portal, the default sign in is configured by default to accept username and password. You can change this.

Go to your API Management Service in Azure Portal | Security | Identity, as you can see we have all the popular options such as Azure Active Directory, Facebook, Google, Microsoft as Identity provider. You may need to add or remove the Providers according to your business needs.

Go back to the Developer Portal and register with any secondary email, you will get confirmation email with link, click on the link to activate the user. Now login to the portal and navigate to the API tab. By Default, we have Echo API listed.

This window will show all the API that are available to consume, click on Echo API, you will see the window like below. By default, first resource is selected and in order to call this resource we need Ocp-Apim-Subscription-Key, you can get this key by subscribing to the Api. You can also click on Try it button to call the resource in the browser, we also have API Definition button if you want to download the API definition in WADL or Open API format.

Let us get our subscription ID, click on Products tabs, choose unlimited for now, we will talk about product later on and click subscribe and confirm the subscription.

Once you are done, a thank you email will be sent to you and you will see screen link below. Right now our unlimited product requires confirmation from Administrator side. So let us go to the Azure Portal and activate our subscription.

Back in the Azure Portal, click on Products | select Unlimited | subscriptions

We have two subscribers here, first one the API Management Service owner who have created this service, and second subscription entry is that we have just submitted earlier. Click on … button and choose Activate subscription and then click yes.

Now go back to Developer portal and refresh, you can see that subscription state is active now and you can also see the Primary key and secondary key.

Next step is to test the Echo service, click on APIS tab, select echo API and click on try. You can see now that the subscription key is automatically populated for you, you just need to click on send.

The response will be shown underneath of the send button.

Now let us create our own API and configure it with the Azure API Management, coming up next