API Integration & Caching
Azure API Management, Azure Cache for Redis, CDN, and Front Door β design API layers that are secure, performant, and cost-efficient.
API and caching design
API Management is the front door to your APIs. It handles authentication, rate limiting, transformation, and analytics β so your backend services focus on business logic.
Caching is the shortcut. Instead of computing the same result 1,000 times, compute it once and cache the answer. Azure Cache for Redis handles in-memory caching. Azure CDN and Front Door cache content at edge locations close to users.
Azure API Management
| Feature | What It Does |
|---|---|
| API Gateway | Single entry point β routes requests to backend services |
| Policies | Transform requests/responses, authenticate, rate-limit, cache, validate |
| Developer Portal | Self-service portal for API consumers (docs, try-it, API keys) |
| Products | Group APIs with usage quotas and terms β publish to specific audiences |
| Analytics | Request volume, latency, errors, geographic distribution |
APIM tiers
| Factor | Consumption | Developer | Standard v2 | Premium v2 |
|---|---|---|---|---|
| Scaling | Serverless (auto) | 1 unit | Configurable units | Configurable units |
| SLA | 99.95% | No SLA | 99.95% | 99.99% |
| VNet integration | No | Yes | Outbound VNet integration | VNet injection (full inbound+outbound) |
| Multi-region | No | No | No | No (classic Premium required) |
| Self-hosted gateway | No | Yes (for dev/test) | No | No |
| Cost | Pay per call | ~$50/mo | ~$300+/mo | ~$3,000+/mo |
| Best for | Low traffic, serverless APIs | Dev/test | Production single-region | Enterprise, VNet isolation |
π Marcusβs APIM design: NovaSaaS exposes APIs to partners:
- Standard v2 tier with outbound VNet integration
- OAuth 2.0 validation policy β validates JWT tokens from partner Entra ID apps
- Rate limiting β 1,000 requests/minute per partner
- Response caching policy β cache GET responses for 5 minutes (reduces backend load by 80%)
Azure Cache for Redis
| Use Case | Description | Pattern |
|---|---|---|
| Data caching | Cache database query results | App checks cache first β hit = return cached, miss = query DB + cache result |
| Session state | Store user sessions across web farm | Centralised session store β all instances share session data |
| Message broker | Lightweight pub/sub | Redis pub/sub for real-time notifications |
| Distributed lock | Prevent concurrent processing | Redis SETNX for cross-instance coordination |
Redis tiers
| Tier | Memory | HA | Best For |
|---|---|---|---|
| Basic | 250 MB - 53 GB | No SLA, no replication | Dev/test |
| Standard | 250 MB - 53 GB | Primary + replica (99.9% SLA) | Production caching |
| Premium | 6 GB - 120 GB | Clustering, geo-replication, VNet, persistence | Enterprise, high throughput |
| Enterprise | 12 GB - 2 TB | Redis Enterprise features, active geo-replication | Mission-critical, multi-region |
CDN and Front Door
| Factor | Azure CDN | Azure Front Door |
|---|---|---|
| Primary purpose | Static content caching at edge | Global load balancing + WAF + caching |
| Routing | Simple (origin-based) | Advanced (URL path, header, geography) |
| WAF | No β use Front Door for WAF | Full WAF with custom rules and bot protection |
| SSL offloading | Yes | Yes + custom domain certificates |
| Caching | Static content (images, CSS, JS) | Static + dynamic content caching |
| Health probes | Yes | Yes + fast failover |
| Best for | Static websites, media delivery | Global applications needing WAF + routing + caching |
π¦ Elenaβs edge design:
- Front Door Premium with WAF protecting all customer-facing APIs
- Custom WAF rules blocking known attack patterns and geo-restricting to operating countries
- Caching for API responses that donβt change per-user (product catalogs, exchange rates)
- Private Link origin connection β backend services never exposed to the internet
Knowledge check
π NovaSaaS exposes APIs to 50 partner companies. Each partner needs rate limiting, JWT validation, and the ability to discover APIs through a self-service portal. Which service should Marcus use?
π¦ Elena's trading platform queries Azure SQL for account balances on every transaction. The database is overloaded at 90% DTU during peak hours. Balances change frequently and stale data could cause overdrafts. Which caching strategy should Elena recommend?
π¬ Video coming soon
Next up: Configuration and deployment automation β App Configuration & Automated Deployment.