Same food delivery app. Same customers. Same Azure SQL database. Built two ways: an insecure architecture and a secure one.
On launch day, both versions work perfectly. That’s the whole problem — nothing tells you which one you built until something goes wrong.
What do the two architectures look like?
Before — the app talks straight to the database. It carries a connection string and queries Azure SQL itself. It’s fast, it’s simple, and it works, which is exactly why it ships.
After — the app goes through Azure Front Door to your own API, and your API talks to a database that has no public address at all.
Figure 1 — the same app built two ways. The left is shorter, which is exactly why it ships.
Where the two designs differ
At six moments. For the first, you genuinely can’t tell them apart. By the sixth, one of them can’t be fixed without rebuilding it.
Moment
Before (app → database)
After (app → API → private SQL)
1. A real customer orders
40ms
52ms — nobody notices
2. Someone unzips the app
Finds a connection string with a password
Finds a token that expires in an hour, for one user
3. He connects to the database directly
It answers — he has valid credentials
No address to connect to
4. He asks for someone else’s order
Nowhere to put an owner check
API filters by the user id in the token
5. You rotate the secret
New build, store review, broken old installs
One command, nobody notices
6. You need to change anything
An app release, measured in days
A server change, measured in minutes
Moment 3 is the one that surprises people. From the database’s point of view, the attacker’s login is completely legitimate — he’s using the same credentials as every installed copy. In the “after” design, publicNetworkAccess is Disabled and the server isn’t on the internet at all.
Moment 4 is the bug that sits at number one on the OWASP API Security Top 10. The fix is a WHERE clause in your API, covered in the full request-flow post. In the “before” design there’s no API, so there’s nowhere to write it.
Response time. In the “before” design, every security fix is an app release, so your response to any incident is measured in days and gated by a store reviewer you don’t control. In the “after” design, every fix is a server-side change you can ship before lunch.
Why the first design is so common
It isn’t laziness. Direct database access is honestly the fastest path to a working prototype, mobile SDKs make it easy, and nothing about it feels wrong while you’re building. The bill arrives later, and it arrives as an architecture change instead of a bug fix.
How do you migrate without a big-bang rewrite?
You don’t have to do it in one go:
Stand up an API in front, even if at first it only proxies the same queries.
Ship an app version that calls the API. Leave the old path working.
Add authentication, then owner checks.
When enough users have updated, turn off public network access on the database.
Key takeaways
Both architectures behave the same for a legitimate request; they only diverge at failure and change moments.
Direct database access is a reasonable prototype — the mistake is launching with it.
Migrate in stages: proxy first, add auth and owner checks, close the database’s public access last.
The ongoing cost of the insecure design is response time: every fix waits on an app store review.
The secure design costs more up front; the insecure one costs more later, repeatedly, at the worst possible moment.
Answer the questions, then submit to see your score and the explanations. Each question is tagged with the
certification exam that covers the skill:
SC-500, AZ-305.
SC-500Secure storage, databases, and networking
Direct access means the app carries credentials and the database must be reachable from the internet. To the database, the attacker's login looks completely legitimate. In the secure design the app holds only a short-lived user token.
AZ-305Design infrastructure solutions
A real customer request takes 40 ms in one design and 52 ms in the other, and nobody notices. The difference is that every fix in the insecure design is an app store release gated by a reviewer, and in the secure one it's a server-side change you control.
AZ-305Design infrastructure solutions
Proxy first, ship the new app, add authentication and owner checks. The hole stays open until public access is disabled, and that can only happen after the new app has rolled out widely. That wait is why doing it before launch is cheaper.
SC-500Secure compute
The owner check is a WHERE clause in your API that filters by the user ID in the token. With no API in the path, the client queries the database itself, so there is no trusted place to write that rule.
AZ-305Design infrastructure solutions
It isn't laziness. Mobile SDKs make direct database access easy and there are fewer moving parts. The cost arrives later, as an architecture change rather than a bug fix.
0 of 5 answered
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.
Is it safe for a mobile app to connect directly to Azure SQL?
No. To connect directly, the app has to carry a connection string with credentials, and the database has to be reachable from the internet. Anyone who unzips the app gets both. The app should call your own API, and the database should have public network access disabled.
Why does an insecure app-to-database architecture ship in the first place?
It is not laziness — it is genuinely the fastest way to a working prototype. Mobile SDKs make direct database access easy, there are fewer moving parts, and nothing feels wrong while you are building. The cost shows up later, as an architecture change rather than a bug fix.
How do you migrate from direct database access to an API-fronted architecture without downtime?
Stand up an API that initially just proxies the same queries, ship an app version that uses it while leaving the old path working, add authentication and then owner checks, and only once enough users have updated, turn off public network access on the database. That last step is what actually closes the hole.
What is the real cost difference between an insecure and a secure mobile architecture?
Not performance — a real customer request is within a few milliseconds in both. The real cost is how fast you can respond: in the insecure design every security fix needs an app store release gated by a reviewer, while in the secure design every fix is a server-side change under your control.
Front Door, your API, Microsoft Entra ID, authorization and a private database — the five layers that stand between a mobile app and its data on Azure.
Five real attacks on a mobile backend, matched one-for-one to the Azure service that stops each — and the default setting that quietly undoes the last one.
viewsRead →
Ask Suthahar
Answers from the article instantly
MSDEVBUILD
/ blog Multi-Stack Dev Build · by Suthahar Azure
Since 2007
India · Malaysia Speaks English and Tamil
About the speaker
Suthahar Jegatheesan
Cloud, AI & Mobile Solutions Architect
Helping the IT industry since 2007, with a passion for giving developers a helping
hand across India and Malaysia.
19+years in IT
5M+views
50+sessions
15,000+developers
Recognition
Microsoft Azure Content Hero
C# Corner MVP
Top 100 Microsoft Azure Blogs
Microsoft Certified Trainer
LinkedIn in/jssuthahar
Is it safe for a mobile app to connect directly to Azure SQL?
No. To connect directly, the app has to carry a connection string with credentials, and the database has to be reachable from the internet. Anyone who unzips the app gets both. The app should call your own API, and the database should have public network access disabled.
Why does an insecure app-to-database architecture ship in the first place?
It is not laziness — it is genuinely the fastest way to a working prototype. Mobile SDKs make direct database access easy, there are fewer moving parts, and nothing feels wrong while you are building. The cost shows up later, as an architecture change rather than a bug fix.
How do you migrate from direct database access to an API-fronted architecture without downtime?
Stand up an API that initially just proxies the same queries, ship an app version that uses it while leaving the old path working, add authentication and then owner checks, and only once enough users have updated, turn off public network access on the database. That last step is what actually closes the hole.
What is the real cost difference between an insecure and a secure mobile architecture?
Not performance — a real customer request is within a few milliseconds in both. The real cost is how fast you can respond: in the insecure design every security fix needs an app store release gated by a reviewer, while in the secure design every fix is a server-side change under your control.
Get notified about new articles
A new version is ready
Install MSDEVBUILD on your Home Screen
Install on iPhone or iPad
Apple only allows adding an app from Safari. Three quick taps:
Tap the Share button
— bottom bar on iPhone, top-right on iPad.
Scroll down and tap Add to Home Screen.
Tap Add, then open MSDEVBUILD from the new icon — it launches like an app, and only then can you turn on notifications.
You're not in Safari right now. Open blog.msdevbuild.com in Safari, then follow these steps.