1. APIM Role in Architecture

APIM implements the facade pattern — a single, consistent entry point that hides the complexity of multiple backend services. This decouples frontend consumers from backend implementation details and centralises cross-cutting concerns.

Cross-Cutting Concerns Handled by APIM

  • Authentication & authorization — validate tokens before traffic reaches backends
  • Rate limiting & throttling — protect backends from burst traffic
  • Caching — reduce backend load for read-heavy APIs
  • Request/response transformation — reshape payloads without changing backends
  • Logging & analytics — unified telemetry across all APIs
  • Versioning & deprecation — expose stable contracts while evolving backends
Architecture principle: Never expose raw backend endpoints to external consumers. APIM provides the abstraction layer that lets you refactor, version, or replace backends without breaking client contracts.

2. APIM Tiers — Decision Matrix

Choosing the right tier is a cost-vs-capability trade-off that appears frequently on AZ-305.

Tier SLA VNet Multi-Region Dev Portal Scale Units Best For
Consumption99.95%AutoServerless, low-traffic, pay-per-call
DeveloperNo SLA1 (no scale)Dev/test, prototyping
Basic99.95%Up to 2Small production, no portal needed
Standard99.95%Up to 4Medium production workloads
Premium99.99%Up to 12+Enterprise, VNet, multi-region, compliance
Exam tip: Only Premium supports VNet integration (internal or external mode) and multi-region gateway deployment. If the scenario mentions "private backend" or "multiple regions," the answer is Premium.

3. APIM Architecture

Every APIM instance comprises three logical components:

  • Gateway (data plane) — proxies API calls, enforces policies, routes to backends. This is the performance-critical path.
  • Management plane — Azure Resource Manager APIs + Azure portal experience for configuring APIs, products, policies, users.
  • Developer portal — auto-generated, customisable documentation site where API consumers discover, test, and subscribe to APIs.

Policy Pipeline

Policies execute at four stages of a request lifecycle:

  1. Inbound — runs before the request reaches the backend (auth, rate-limit, transform)
  2. Backend — runs just before forwarding (set backend URL, client cert)
  3. Outbound — runs after backend response (transform, cache-store, headers)
  4. On-error — runs if any stage throws an exception
<policies>
    <inbound>
        <rate-limit calls="100" renewal-period="60" />
        <validate-jwt header-name="Authorization" ...>
    </inbound>
    <backend>
        <forward-request />
    </backend>
    <outbound>
        <cache-store duration="300" />
    </outbound>
    <on-error>
        <set-body>@("Error: " + context.LastError.Message)</set-body>
    </on-error>
</policies>

4. Key Policies

Policy Stage Purpose Example
rate-limitInboundThrottle per subscription key100 calls/min
rate-limit-by-keyInboundThrottle by custom expression (IP, user)By caller IP
quotaInboundHard cap over longer period10,000 calls/month
cache-lookup / cache-storeInbound / OutboundBuilt-in response cachingCache GET for 5 min
validate-jwtInboundValidate OAuth 2.0 / OIDC tokensCheck issuer, audience, claims
set-headerAnyAdd/remove/replace headersStrip internal headers outbound
set-bodyAnyTransform request/response bodyXML → JSON conversion
rewrite-uriInboundChange URL path before forwarding/v2/orders → /api/orders
mock-responseInboundReturn static response without calling backendPrototyping, testing
retryBackendRetry failed backend calls3 retries, exponential back-off
send-requestAnyCall an external service (e.g., lookup cache, enrich)Fetch user profile, attach to request
Policy composition: Policies can be scoped at four levels — Global → Product → API → Operation. Lower scopes inherit and can override higher scopes using <base /> to control ordering.

5. Backend Abstraction: Versioning & Revisions

Versioning Strategies

Scheme Example Pros Cons
URL path/v1/ordersExplicit, easy to cache/routeURL changes per version
Query string/orders?api-version=2024-01-01URL stays same; Azure's own patternHarder to discover
HeaderApi-Version: 2Clean URLsNot visible in browser, harder to test

Revisions vs Versions

  • Revision — non-breaking changes (bug fix, add optional field). Consumers don't notice. You can test a revision before making it current. Think: git branch before merge.
  • Version — breaking changes (removed field, new auth model). Consumers choose which version to call. Think: v1 vs v2 coexisting.
Architecture pattern: Use revisions for iterative safe changes, versions only when you must break the contract. APIM lets you run both simultaneously, routing by version identifier.

6. Security Patterns

OAuth 2.0 Flow Through APIM

Security Layers

Mechanism Where Use Case
Subscription keysAPIM inboundIdentify callers, basic access control per product
OAuth 2.0 / JWT validationAPIM inbound (validate-jwt)Delegated auth, fine-grained claims-based access
Client certificates (mTLS)APIM inboundPartner-to-APIM mutual authentication
Managed IdentityAPIM → BackendAPIM authenticates to backend without secrets (e.g., to Azure Functions, App Service)
IP filteringAPIM inbound policyRestrict to known CIDR ranges
Exam tip: Subscription keys alone are NOT sufficient security for production APIs. Always layer with OAuth 2.0 (validate-jwt) or client certificates. Subscription keys are an identification mechanism, not an authentication one.

7. Networking: VNet Modes & Self-Hosted Gateway

VNet Integration Modes (Premium Only)

Mode Gateway Accessible From Backend Accessible From Use Case
External Internet (public IP) VNet + Internet Public-facing API with private backends
Internal VNet only (private IP) VNet only Fully private API platform; expose via App Gateway / Front Door

Self-Hosted Gateway

A containerised gateway you deploy on-premises, in other clouds, or at the edge. It connects back to the APIM management plane for configuration sync.

  • Runs as a Docker container or Kubernetes deployment
  • Enables hybrid/multi-cloud API governance with a single control plane
  • Policies and API definitions sync from the Azure-hosted management plane
  • Available on Developer and Premium tiers
Architecture pattern: For internal-only APIM, front it with Azure Application Gateway (WAF) or Front Door to add DDoS protection and global routing while keeping the gateway private.

8. Multi-Region Deployment

Premium tier supports deploying additional gateway units to multiple Azure regions, providing:

  • Lower latency — clients route to the nearest gateway via Traffic Manager / Front Door
  • Higher availability — if one region fails, traffic shifts to healthy regions (99.99% SLA)
  • Compliance — keep data processing in-region where required

How It Works

  1. Primary region hosts the management plane (one region always "primary")
  2. Additional regions host gateway units only
  3. Configuration syncs automatically from primary to all regions
  4. Each region can have its own backend pool (use set-backend-service policy with expressions to route by region)
Exam tip: Multi-region APIM requires Premium tier. Each additional region adds gateway capacity but the management plane stays in the primary region. You're billed per gateway unit per region.

9. Real-World: Banking API Platform

🏦 Scenario: Open Banking Partner API

A bank exposes internal services (accounts, payments, standing orders) to fintech partners via APIM.

Architecture Decisions

  • Tier: Premium — requires VNet integration (backends in private VNet) and multi-region for DR
  • Networking: External VNet mode — partners call from internet, backends are VNet-private
  • Security stack:
    • Partners authenticate via OAuth 2.0 (client credentials flow) → APIM validates JWT with validate-jwt
    • Client certificates required for high-value payment APIs (mTLS)
    • Subscription keys per partner for identification & analytics
    • APIM uses managed identity to call backend Azure Functions
  • Rate limiting: Per-partner quotas (10,000 calls/day basic tier, 100,000 premium tier) via Products
  • Audit: All requests logged to Event Hub → Splunk for regulatory compliance
  • Versioning: URL path scheme (/v1/accounts, /v2/accounts) — partners migrate at their own pace

Result

50+ fintech partners onboarded via the developer portal. Zero backend exposure. Rate limiting prevented a partner's runaway script from impacting other consumers. Audit trail satisfies PSD2 regulatory requirements.

10. Knowledge Check

Q1: Which APIM tier is required to deploy the gateway inside a Virtual Network?

Q2: In the APIM policy pipeline, at which stage does cache-store execute?

Q3: What is the difference between a revision and a version in APIM?

Q4: How should APIM authenticate to a backend Azure Function without storing secrets?