Showing posts with label Azure ApiManagement. Show all posts
Showing posts with label Azure ApiManagement. Show all posts

Tuesday, 16 May 2017

Azure API Management - Add rate limiting & consuming the api (Part 4)


Introduction

This is part 4 of a series of blog posts where I will be talking about how rate-limiting is configured. We will look at the developer's perspective of the API (developer portal).

In the last post we published the "yo-blog" API via the publisher portal. The URL of the publisher & developer portal is https://mgtdemo.portal.azure-api.net/. In this post we will need to log into this portal as both:
  • An API Publisher
  • An API consuming developer (using the API)



Rate Limiting & Products

Rate limiting is tied to the "Products".

"Products" essentially refer to your API offerings. In this example we will create an API offering with the following settings.

Name  Api Testing Plan
Description Subscribers will be able to run 1 call/minute up to a maximum of 20 calls/month.
Approval Administrator approval is required.
Requires subscription Yes
Subscription Requires Approval Yes
Multiple simultaneous subscriptions No
Allowed Groups Administrators, Developers, Guests
Quota 10 calls per 10 days
Rate Limit 1 call per minute


To accomplish this, log into the publisher portal & click "Products" & click
ADD Product". Then follow the screenshots below.

Click Products & then click ADD PRODUCT

Then add the details for the new product. Then click Save.


Then click on the newly created product


Next navigate to visibility & check the appropriate visibility then save

Also, don't forget to "Publish" your APIs.


Rate limiting a product

You now need to click on policies & then click Add Policy



As you can see, a policy does not exist for the "Api Testing Plan". Click it to create one.
You then need to click the option to "Limit call rate per subscription". This should automatically set the correct XML config like so: (check next image)




After modifying the values, your XML looks like so ..

Your rate limit is 1/ per 60 seconds & quota is 10 calls per 10 days

Assign the Product to an API

You need to navigate to your API, then navigate to the Product tab & delete the "Starter" Product & add the "API Testing Plan" product.








Consuming the API

Now that the APIs have been published, lets look at what a consuming developer experiences. 

Our APIs are now published & available at the API Portal https://mgtdemo.portal.azure-api.net. When they navigate to the URL, they will see a default home page. If your API's product allows for "Guest" visibility & DOES NOT require subscription,  your API definition will also be visible. This means by default, any API linked to a "Starter" product offering will be visible without logging in.

(More to come ...)






I will be writing a series of posts to cover this topic, stay tuned ..

- Part 1: Azure API Management - An introduction 
- Part 2: Azure API Management - Your back-end api
- Part 3: Azure API Management - Creating a gateway & exposing your api
- Part 4: Azure API Management - Add rate limiting & consuming the api
- Part 5: Azure API Management - Add security

Monday, 1 May 2017

Azure API Management - Your back-end api (Part 2)


Introduction

This is part 2 of a series of blog posts where I will be talking about exposing your back-end apis via Azure API Management as production ready apis.

In this post I will discuss a sample scenario that we will use throughout this series to explore the capabilities of the platform. 

Lets look at the following sample scenario.

Sample Scenario

I have an existing "Back-End-Service" that you wish to serve up via Azure API Management. This service essentially exposes user, post & comment data related to a blogging site. It's called "Yo Blog". 

I have made this "Back-End-Service" publicly accessible (http://52.175.244.3:8080) but in a realistic scenario this would be hidden in a private network with some form of security on top of it. If you would like to follow along, you can create your own serve as shown here https://github.com/rohit-lakhanpal/azure-api-mgt-resources.

As you can see, the following REST endpoints are exposed: 

User Related Operations: Operations about user
Operation
Description
Fetch a list of all users
Create user
Find user by ID

Post Related Operations: Operations about blog posts & comments
Operation
Description
Fetch a list of all posts
Create post
Find post by ID
Find comments by post ID


An API Definition

Based on the "Back-End-Service" that you are planning to expose, you  now need to create an API definition. This is something that we will be using in the next stage to add 

I have created an API definition using Swagger. This is accessible at https://raw.githubusercontent.com/rohit-lakhanpal/azure-api-mgt-resources/master/swagger.json (Note: If you have created your own API, you will need this link before the next step.)





I will be writing a series of posts to cover this topic, stay tuned ..

- Part 1: Azure API Management - An introduction 
- Part 2: Azure API Management - Your back-end api
- Part 3: Azure API Management - Creating a gateway & exposing your api
- Part 4: Azure API Management - Add rate limiting & consuming the api
- Part 5: Azure API Management - Add security


Thursday, 27 April 2017

Azure API Management - An introduction (Part 1)



Is there an API for that?

If you've worked for a SaaS vendor, I'm fairly certain that at some point you've been asked this question. For most apps today, integration is no longer a should-have but a must-have requirement.

As a developer we love writing amazing json:api compliant REST endpoints that expose app functionality BUT we often neglect the realities of hosting these endpoints in a production-ready state.

This is where Azure API Management comes in. Here's the pitch from Microsoft:

Azure API Management as a turnkey solution for publishing APIs to external and internal customers. Quickly create consistent and modern API gateways for existing back-end services hosted anywhere, secure and protect them from abuse and overuse, and get insights into usage and health. Plus, automate and scale developer on-boarding to help get your API program up and running. 

What is it?

  • Serves as a proxy that sits between your back-end services/apis & the calling apps
  • Essentially a common facade on top of existing apis
  • This "intermediate layer" allows you to quickly create consistent and modern API gateways for existing back-end services hosted anywhere
  • Turnkey solution for publishing apis to external and internal consumers.

Why use Azure API Management?

  • Perfect way to easily package & publish your existing back-end apis
  • Allows easy developer on-boarding (serves as a self-service portal)
    • Ramp-up uptake with docs, samples & an api console
    • Provide API documentation and an interactive console
    • Allows API discoverability
  • Enhance back end services by
    • Throttle, rate limit and quota your APIs
    • Monitor health of your APIs and quickly identify errors
    • Gain analytic insights on how your APIs are being used
  • Allows managing your service via the Azure portal, REST API, PowerShell, or Git repository