Every list of “API security advice” has the same items on it. What almost none of them tell you is that the order matters as much as the items do.
Here are the five layers for a mobile API on Azure, in the order I’d add them to a brand-new ASP.NET Core API, and why.

Step 1 — How do you enforce HTTPS on a mobile API?
Turn HTTP off, don’t just redirect it. On App Service, set HTTPS Only = On and a minimum TLS version of 1.2, then add HSTS. A redirect still lets the first request go out in the clear. On a mobile app, that first request usually carries the token.
app.UseHsts();
app.UseHttpsRedirection();
Step 2 — Authentication: proving who is calling
Entra ID issues the token. Your API validates it. It’s a local check against cached signing keys. Microseconds, not a round trip. Validate the audience too. A valid token for a different app is still a valid token. The whole sign-in journey is in what actually happens when you tap Sign in.
Step 3 — Authorization: what the caller may do
A different question, and the one teams skip. Entra ID says she’s Priya. Your API decides that Priya gets Priya’s orders, and nobody else’s.
db.Orders.Where(o => o.UserId == me.GetObjectId())
Then make it fail closed, so an endpoint you forget about is protected by default:
builder.Services.AddAuthorizationBuilder()
.SetFallbackPolicy(new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser().Build());
Step 4 — Secrets: nothing in config
Azure Key Vault holds them, a managed identity fetches them, and appsettings.json holds a vault URI at most. For Azure-to-Azure calls, skip keys entirely. SQL, Storage, Service Bus, Cosmos DB and Azure OpenAI all accept managed identity. The full case is in Azure Key Vault, explained properly.
Step 5 — Monitoring: you find out first
Application Insights for what your API sees, Microsoft Defender for Cloud for what Azure sees. Alert on the rate of 401s and 403s, not just on errors: a spike in 401s is somebody trying credentials, and it’s the earliest warning you’ll get.
Why does the order matter?
Steps 1 to 3 are the doors an attacker walks through, step 4 decides how bad the day is when something else goes wrong, and step 5 decides whether you find out in an hour or on the invoice.
Where rate limiting fits
It’s not one of the five. On its own it isn’t a security boundary. But ASP.NET Core has it built in, and it turns a credential-stuffing bot from a real threat into a nuisance:
builder.Services.AddRateLimiter(o =>
o.AddFixedWindowLimiter("login", w => {
w.PermitLimit = 10; w.Window = TimeSpan.FromMinutes(1);
}));
Partition by user or IP, never globally, or one attacker rate-limits your real customers. The reasoning is in the post on automated attackers.
Key takeaways
- Five layers, in order: HTTPS only, authentication, authorization, secrets, monitoring.
- HTTPS Only has to be a platform setting, not just an app redirect, or the first request still leaks.
- Authentication and authorization are separate steps — a valid token says nothing about which rows the caller may see.
- Secrets live in Key Vault, fetched by a managed identity, never in
appsettings.json. - Monitor the rate of 401/403s; it’s the earliest sign of an attack in progress.
Official documentation: Azure API Management key concepts and access tokens in the Microsoft identity platform.
