Implementing Platform-Level Security in Azure SQL
This lesson explains the layers of Azure SQL protection, and how to distinguish features that sound alike.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the security layers of Azure SQL.
- Choose among network access options.
- Explain Microsoft Entra-only authentication.
- Distinguish transparent data encryption, Always Encrypted and dynamic data masking.
The layers of protection
Azure SQL Database is a managed service, so Microsoft takes care of patching and of the host. The customer remains responsible for who can connect, what they can do, and how the data is protected. Security is arranged in layers, so that a weakness in one does not expose the data. The following table lists the layers.
| Layer | Features | Threat addressed |
|---|---|---|
| Network | Firewall rules, virtual network rules, private endpoints | Connections from unwanted networks |
| Authentication | Microsoft Entra ID and SQL authentication | Unverified identities |
| Authorization | Database roles, row-level security | Excess access by legitimate users |
| Threat protection | Auditing, Advanced Threat Protection | Undetected misuse |
| Data protection | TLS, transparent data encryption, Always Encrypted, dynamic data masking | Theft or exposure of data |
| Security management | Vulnerability assessment, data discovery and classification | Unknown weaknesses |
Network access
An Azure SQL logical server has a public endpoint. Server-level firewall rules admit public IP ranges for every database on the server, and database-level firewall rules apply to one database. Virtual network rules admit a subnet through a service endpoint. The setting Allow Azure services and resources to access this server admits any Azure-hosted client, including those of other customers, so it should normally remain off.
The strongest option is a private endpoint with public network access disabled, which gives the server a private address. Azure SQL Managed Instance is different: it is deployed into a virtual network subnet of its own, so it is private by design, with an optional public endpoint on port 3342.
Reaching Azure SQL
Microsoft Entra authentication
SQL authentication uses a name and a password stored in the database, which means another password to manage, and which offers no MFA or Conditional Access. Microsoft Entra authentication uses central identities, and allows managed identities for applications, MFA for people, and PIM for elevated group membership.
To configure it, set a Microsoft Entra administrator on the server, preferably a group. Then enable Microsoft Entra-only authentication to disable SQL authentication altogether, including the server administrator login. Existing SQL logins are not deleted, but they cannot be used. The setting fails if no Microsoft Entra administrator exists. SQL Security Manager can set it, whereas SQL Server Contributor cannot, which is a deliberate separation of duties. Some features, such as elastic jobs and SQL Data Sync, are not supported with this setting.
az sql server ad-admin create --resource-group RG --server SERVER --display-name "SQL Admins" --object-id GROUP_ID
az sql server ad-only-auth enable --resource-group RG --name SERVERAn application with a managed identity connects by creating a contained user in the database with CREATE USER [app-name] FROM EXTERNAL PROVIDER;, and by receiving a database role with the least rights that it needs.
Entra-only authentication
Encryption and masking
Four data protection features are often confused, and exam scenarios separate them by asking who the protection is against. The following comparison shows what each one does.
Transparent data encryption (TDE) is on by default for new databases. With a customer-managed key, known as bring your own key, the server's identity needs the wrap and unwrap permissions on the key. It protects against theft of files, but a logged-in user with rights sees plain text.
Always Encrypted encrypts specific columns in the client driver, so the database engine never sees plain text. It is the answer when a scenario says that database administrators must not see the data. Dynamic data masking changes only what is displayed: a user sees XXXX-1234 instead of a full card number. It is not encryption, and a user with sufficient rights, or a clever series of queries, can infer values. Row-level security limits which rows a user sees, using a predicate function.
TDE, Always Encrypted or masking?
Security management features
Data Discovery and Classification finds sensitive columns and labels them, and the labels appear in audit logs, so that access to sensitive data can be identified. SQL vulnerability assessment checks configuration against best practices, and it is part of Defender for Azure SQL Databases. Ledger provides tamper evidence for data, by keeping a cryptographic history of changes.
Hiding data from administrators
A hospital stores patient identifiers in Azure SQL Database. Database administrators must be able to manage the database but must never see the identifiers. Application users at the front desk should see only the last four digits. Stolen backups must be unreadable. Which features meet each requirement?
The first requirement needs Always Encrypted, as it keeps the data from the engine and its administrators, with keys held by the client. The third is met by transparent data encryption, which is on by default.
The second needs thought. Dynamic data masking would normally show partial values, but it cannot mask a column that Always Encrypted protects, because the engine sees only ciphertext. The application must therefore perform the partial display after decrypting. This trap shows the value of asking where each feature runs: masking runs in the engine, and Always Encrypted runs in the client.
Does transparent data encryption stop a database administrator from reading data?
Show answer
No. It protects files at rest, and logged-in users see plain text. Always Encrypted addresses administrators.
Exam Tips
Remember for the exam
- Set a Microsoft Entra administrator before enabling Entra-only authentication.
- Always Encrypted protects data from database administrators.
- Transparent data encryption protects files and backups, not query results.
- Dynamic data masking is not encryption.