πŸ” 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:


GET https://your-apim.azure-api.net/products Headers: ocp-apim-subscription-key: your-subscription-key-here

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?

  1. Go to your API Management instance in the Azure Portal

  2. Click on Subscriptions

  3. Choose a product (e.g., Starter, Unlimited)

  4. 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

xml

<inbound> <base /> <set-header name="X-App-Version" exists-action="override"> <value>1.0</value> </set-header> </inbound>

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

FeatureWhat It DoesWhy It Matters
ocp-apim-subscription-keyIdentifies and authenticates API callersEnsures secure, trackable access to APIs
RevisionsCreate editable drafts of your APIsSafely make and test changes without breaking APIs
PoliciesModify requests/responses with XML rulesAdd powerful logic without changing your backend

With these features, Azure API Management becomes more than a gateway — it becomes a central control panel for your API ecosystem.

Comments

Popular posts from this blog

πŸ€– Copilot vs Microsoft Copilot vs Copilot Studio: What’s the Difference?

Automating Unique Number Generation in Dynamics 365 Using Plugins

In-Process vs Isolated Process Azure Functions: What’s the Difference?