Skip to main content

Authentication & Authorization

For a quick comparison of TDE, Always Encrypted, RLS, DDM, and Auditing, see the Security Controls Comparison.

The Security Architecture

Azure SQL Security Defense in Depth
Security Architecture
🔑
SQL Authentication
Username/password stored in DB. No MFA, no central revocation. Legacy method.
🛡️
Microsoft Entra ID
Centralized identity with MFA, conditional access, group-based access. Recommended.
🤖
Managed Identity
Passwordless app-to-DB auth. No secrets, no rotation. Best for all app connections.
👥
Database Roles
db_datareader, db_datawriter, db_owner — control what authenticated users can do.
🔒
Row-Level Security
Filter predicates control which rows each user sees. Multi-tenant isolation.
🎭
Dynamic Data Masking
Masks sensitive data in query results without changing stored data.

Authentication Methods

SQL Authentication

Traditional username/password stored in the database.

  • Server level: CREATE LOGIN → creates a login on the logical server
  • Database level: CREATE USER FOR LOGIN → maps the login to a database user
  • Weakness: passwords stored in the DB, no MFA, no central revocation

Centralized identity with MFA, conditional access, and no password management.

FeatureSQL AuthEntra ID
MFA
Conditional Access✅ (require compliant device, location-based)
Central revocation❌ (must alter each server)✅ (disable in Entra → blocked everywhere)
Group-based access✅ (add users to Entra groups)
Managed Identity✅ (passwordless app auth)
🎯 Exam Focus

Microsoft Entra authentication is the recommended method. For the exam, know that you must configure an Entra admin on the SQL Server before creating Entra users. Only ONE Entra admin can be set per logical server, but it can be a group (best practice: always use a group).

Managed Identity (App-to-Database)

The best pattern for application connections — no passwords, no secrets, no rotation:

Managed Identity Flow
📱
App Service / Function
App has system-assigned managed identity
No credentials stored in code or config
🛡️
Microsoft Entra ID
App requests access token
Entra validates identity automatically
🏷️
Access Token
Entra issues short-lived JWT token
Token scoped to Azure SQL resource
🗄️
Azure SQL Database
Token presented in connection
SQL validates token, grants access per DB user
🏢 Real-World DBA Note

Oracle DBA parallel: This is like Oracle External Authentication + Kerberos, but simpler. The app gets a token from Entra ID automatically — no keytab, no wallet, no password rotation ever. Use this for ALL app-to-DB connections in Azure.

Authorization — Role Hierarchy

Server & Database Role Hierarchy
🏢
Server-Level Roles
sysadmin, securityadmin, serveradmin, dbcreator — control server-wide operations and logins
🗄️
Database-Level Roles
db_owner, db_datareader, db_datawriter, db_ddladmin, db_securityadmin — per-database permissions

Fixed Database Roles — Quick Reference

RoleCan SELECTCan INSERT/UPDATE/DELETECan DDLCan Manage Security
db_owner
db_datareader
db_datawriter
db_ddladmin
db_securityadmin
⚠️ Watch Out

Common exam trap: db_datareader does NOT grant INSERT/UPDATE/DELETE. db_datawriter does NOT grant SELECT. To read AND write, a user needs BOTH roles.

Row-Level Security (RLS)

Controls which rows a user can see. Perfect for multi-tenant applications.

Row-Level Security — Per-Tenant Filtering
📱
App Sets Context
App calls SESSION_CONTEXT with TenantId before queries
🔍
Filter Predicate
Security policy function checks SESSION_CONTEXT vs row TenantId column
Filtered Results
Query returns only rows matching the tenant — transparent to the application

How it works: A filter predicate function checks SESSION_CONTEXT (set by the app) against the row's tenant column. Azure applies this transparently — queries return only matching rows.

🏢 Real-World DBA Note

Oracle DBA parallel: RLS = Oracle VPD (Virtual Private Database). VPD uses policy functions on tables. RLS uses security predicate functions + security policies. Same concept, different syntax. If you've built multi-tenant Oracle apps with VPD, RLS will feel natural.

Dynamic Data Masking

Masks sensitive data in query results without changing stored data:

Mask FunctionWhat It DoesExample
default()Full maskXXXX
email()Masks emailaXX@XXXX.com
partial(prefix, mask, suffix)Custom maskXXXX-XXXX-XXXX-1234
random(start, end)Random number42 (within range)
⚠️ Watch Out

Dynamic Data Masking does NOT encrypt data at rest — it only masks the display. Users with db_owner or UNMASK permission see unmasked data. It's a presentation-layer security feature, not encryption. For true encryption → use Always Encrypted.

Security Feature Comparison (Exam Favorite!)

FeatureProtectsFrom WhomData Changed?
TDEData at rest (files, backups)Physical disk theftNo (transparent)
Always EncryptedSpecific columns (in use)Even DBAsNo (client-side encrypt/decrypt)
Dynamic Data MaskingQuery output displayNon-privileged usersNo (display only)
Row-Level SecurityRow accessWrong tenants/usersNo (filter predicate)
TLSData in transitNetwork sniffingNo (transport encryption)

Flashcards

What is the recommended authentication method for Azure SQL?
Click to reveal answer
Microsoft Entra ID (Azure AD) authentication — supports MFA, conditional access, centralized identity
1 / 6

Quiz

Q1/4
0 correct
Which authentication method is recommended for Azure SQL Database?