💡 Learn more : Azure API Management.
📺 Watch the video : How to get started with Azure API Management.
When you are developing APIs that other people use, you should seriously consider using Azure API Management. This service acts as a gatekeeper in front of your API and adds many features, like:
Let's explore how you can get started with Azure API Management.
We'll start by creating a new Azure API Management instance and putting it in front of an API.
(Create Azure API Management blade in the Azure portal)
When the deployment is done, you can take a look at your API Management instance. When it is new, it is just an empty gateway that is not exposing anything. So let's give it an API to expose and protect:
(Add a new API in the Azure portal)
We now have an API that is protected and exposed by API management. And so, we can try it out. We can test it out right here, from the Azure portal.
(Testing the API in the Azure portal)
When you test the API from the Azure portal, you might notice that you can select a subscription key that is sent with the test, like in the image above. This key authorizes you to use the API as, per default, the API is protected and can't be used without authorization.
You can now also go to the developer portal and test the API. The developer portal is a website that users of the API will visit to test the API and get documentation about it. You can get to the developer portal by clicking on the Developer portal button in the top of the API Management service in the Azure portal.
Once you are in the developer, portal, you can see the API, like in the image below.
(Testing the API in the developer portal)
Now that we have an API that is being exposed and protected by API Management, we can start to monetize it. We do this using products and subscriptions.
You've already seen products when you added the API in the previous step. A product in API Management is a thing that represents API capabilities that you can sell to your customers. In a new API Management instance, there are already two products added, the Starter and the Unlimited product. In the previous step, we've associated the Starter product with the demo API. This means that customers can create a subscription to the Starter product and get access to the API as far as the product allows it. The product itself defines which capabilities customers (users) can use and how much of them they can use.
So the relationship between subscriptions, products and API is this:
Users can create subscriptions for your API by singing up in the developer portal. This is your public portal that you can use to sell subscriptions to your APIs and for users to start using it. The developer portal comes with lots of features out-of-the-box and you can customize it fully to fit your style and support your payment methods.
(Users can sign up to use an API in the developer portal)
The products determine which capabilities you expose and how much they can be used. The starter product, for instance, has some policies set on it that limit its usage. It has a rate limit of 5 calls per 60 seconds. And a quota that restricts the user to a total of 100 calls per 7 days. You can also restrict the amount of data going in and out and even transform XML to JSON using policies.
(Set policies on a product in the Azure portal)
You can set policies on a product, and you can even apply them to a specific user or subscription.
And once you have users that use your APIs, you can monitor how they use your API. You can track this in detail by analyzing how many call a certain user makes and from where the calls are made. Pretty cool, right?
(Analyze API usage in the Azure portal)
Azure API Management is a very powerful and versatile product. In this post, you've seen only some of its capabilities. You can do a lot more with API Management, like version your API, secure it and monitor it. Go and check it out!