Secure a Mobile API in Five Steps: The Order Is the Whole Point

HTTPS, authentication, authorization, secrets, then monitoring — five layers for a mobile API on Azure, and why doing them out of order defeats the point.

Suthahar Jegatheesan By Suthahar Jegatheesan Published

Azure 4 min read —views
Article banner. On the left, the eyebrow "Azure, Securing a Mobile App" above the title "Five steps, in this order" and the line "Secure a mobile API on Azure. The order carries the value.", with the MSDEVBUILD wordmark and the author name below. On the right, three stacked boxes joined by arrows: a grey box reading "HTTPS only, then who are you", an arrow labelled "then" to an amber box reading "Then what may you do, an owner check", and an arrow labelled "last" to a green box reading "Secrets, then monitoring, you find out in an hour".

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.

Five steps with icons, in order. 1, a padlock: HTTPS only, so nothing travels in plain text. 2, a shield: authentication, Entra ID gives the user a signed pass and your API checks it. 3, a filter: authorization, Priya only gets Priya's orders, checked in your own code. A red dashed line after step 3 reads "1-3: the doors an attacker must pass". 4, Key Vault: secrets live in Key Vault, not your code. 5, Application Insights: monitoring alerts you when failed logins spike. A green box reads "Do them in this order. You can add monitoring last. You can't add HTTPS last."

Figure 1 — the five layers, in the order to add them.

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.

Test yourself · 5 questions

Check what you learned

Answer the questions, then submit to see your score and the explanations. Each question is tagged with the certification exam that covers the skill: AZ-305, SC-500.

  1. AZ-305 Design identity, governance, and monitoring solutions

    1. What is the right order for the five security layers of a new mobile API?
  2. SC-500 Secure compute

    2. Why isn't an HTTP-to-HTTPS redirect enough for a mobile API?
  3. SC-500 Manage identity, access, and governance

    3. Entra ID has said the caller is Priya. Which step decides that Priya sees only Priya's orders?
  4. SC-500 Secure compute

    4. Where does rate limiting fit among the five layers?
  5. SC-500 Manage and monitor security posture

    5. Which pair of services does the monitoring step use?
0 of 5 answered

Your result

These are practice questions written from this article, not questions taken from a real exam. Exam tags follow the skills listed in each exam's official study guide on Microsoft Learn.

Was this useful?

Share

Found a mistake or an outdated step? Edit this page on GitHub

Frequently asked questions

What are the steps to secure a mobile API on Azure?
Five, in order: enforce HTTPS only at the platform level, authenticate callers with Microsoft Entra ID tokens, authorize every request in your own code (for example, filtering to rows the caller owns), keep secrets in Azure Key Vault behind a managed identity, and monitor with Application Insights and Defender for Cloud.
Is redirecting HTTP to HTTPS enough for a mobile API?
No. A redirect still lets the first request go out in the clear, and on a mobile app that first request often carries the token. Turn HTTPS Only on and set a minimum TLS version at the platform level, then add HSTS, rather than relying on an application redirect alone.
What is the difference between authentication and authorization in an API?
Authentication answers "who are you" — Microsoft Entra ID issues a token and your API validates its signature, issuer and audience. Authorization answers "what may you do", and is enforced in your own code, typically by filtering a query to rows the caller owns.
Why does secrets management come after authentication and authorization?
HTTPS, authentication and authorization are what an attacker has to get through to reach data at all, so they close off access first. Secrets management decides how much damage a separate failure causes, and monitoring decides how quickly you find out — both matter, but neither blocks an attacker on its own.
Article banner. On the left, the eyebrow "Azure, Securing a Mobile App" above the title "One secret left over" and the line "The credential that opens the vault. A managed identity removes it.", with the MSDEVBUILD wordmark and the author name below. On the right, three stacked boxes joined by arrows: a grey box reading "Six secrets into Key Vault, the tutorial ends here", an arrow labelled "the leftover" to a red box reading "A ClientSecret opens the vault, one master secret", and an arrow labelled "the fix" to a green box reading "A managed identity, nothing left to leak".

Next in this series · Part 7 of 10

5 min

Azure Key Vault Explained: The One Secret Tutorials Never Remove

Moving every secret into Key Vault leaves exactly one behind — the credential that opens the vault. A managed identity is what finally gets you to zero.

Continue the series
Part 5 of 10Five Mobile App Security Vulnerabilities a Scan Finds — and Nobody Chose

Get new posts by email

New technical articles, Azure AI and GitHub Copilot updates, and upcoming events. No spam, unsubscribe anytime.

Comments

Your turn

How did Suthahar's articles help you?

If something here saved you time or unblocked a real project, I'd love to hear about it. Submissions are reviewed before they appear on the site.

0/1500 · minimum 10 characters

Never published — used only to verify your feedback.

Your name, company, and role appear publicly if published. Nothing else is collected.

↑↓ navigate ↵ open