π Azure API Management Explained: Subscription Keys, Revisions, and Policies
As organizations increasingly expose APIs to partners, developers, and applications, Azure API Management (APIM) becomes a powerful gateway to control and secure API access.
In this blog, we’ll break down three fundamental concepts that every APIM user should know:
-
ocp-apim-subscription-key
(The gateway key) -
Revisions (Safe API evolution)
-
Policies (Runtime customization)
Let’s dive in.
π ocp-apim-subscription-key
: Your Gateway Key
When you expose your APIs through Azure API Management, you don’t want just anyone to call them. This is where the ocp-apim-subscription-key
comes in.
What Is It?
It’s a subscription key that uniquely identifies and authenticates the API caller. Think of it as an API password.
This key is passed in the HTTP header like this:
Why Do We Need It?
-
Authentication: Confirms the caller is allowed to access the API
-
Throttling & Quotas: Track usage by user/app
-
Monitoring: Logs, analytics, and performance insights are linked to the key
How to Get One?
-
Go to your API Management instance in the Azure Portal
-
Click on Subscriptions
-
Choose a product (e.g., Starter, Unlimited)
-
Copy the primary key or secondary key
Now your client app can call your API securely!
π Revisions: Update Your API Without Breaking Stuff
Imagine your API is already live, but now you need to:
-
Add a new endpoint
-
Update a policy
-
Change a backend service
You don’t want to disrupt live consumers. That’s where Revisions come in.
What Are Revisions?
Revisions let you maintain multiple configurations of an API — like working drafts — without affecting the published version.
Example Scenario
-
You have
ProductAPI
at Revision 1 (live) -
You create Revision 2 to test a new endpoint
-
Once everything works, you make Revision 2 current
-
Existing consumers are upgraded safely
It’s safe. It’s elegant. It’s API lifecycle management done right.
Revisions are internal versions. If you want public versions (like
v1
,v2
in the URL), use Versions, which is a separate feature.
π‘️ Policies: The Power Rules of APIM
Want to control how requests and responses behave?
Policies are XML-based rules you apply at different levels (global, product, API, or operation). They run at runtime and are incredibly powerful.
What Can Policies Do?
-
Add/remove/transform headers
-
Validate tokens
-
Enforce CORS
-
Perform rate limiting
-
Rewrite URLs
-
Mock responses or fallback behavior
Sample Policy: Add a Header
This simple policy adds a custom header to every inbound request — no code changes needed in your API.
Where Can You Apply Them?
-
At the Product level – for all APIs in that product
-
At the API level – to affect every operation
-
At the Operation level – granular control
Policies give you full control of request and response flow, right in the APIM portal.
✨ Wrap-Up: Why It All Matters
Feature | What It Does | Why It Matters |
---|---|---|
ocp-apim-subscription-key | Identifies and authenticates API callers | Ensures secure, trackable access to APIs |
Revisions | Create editable drafts of your APIs | Safely make and test changes without breaking APIs |
Policies | Modify requests/responses with XML rules | Add powerful logic without changing your backend |
Comments
Post a Comment