Courseiva
DP-300Chapter 8 of 14Objective 3.2

Securing Data at Rest and in Transit

Exam domain 3.2, 'Secure data at rest and in transit', addresses a core anxiety: how do you stop your data from being stolen whether it's sitting in a database or speeding across the internet? For the DP-300 exam, this is one of the most heavily tested security topics because a single mistake here can expose millions of customer records. Getting this right is what separates a front-line database administrator from someone who accidentally leaks data to the whole world.

12 min read
Intermediate
Updated Jul 23, 2026
Editorial oversight: Johnson Ajibi· Security Systems Architect · MSc IT Security · IEEE Senior Member

A simple way to picture Securing Data at Rest and in Transit

The Glass Safe and Armoured Courier Analogy

Have you ever left a packed suitcase on your hotel bed while you popped down for breakfast? That suitcase is your data, and the hotel room is the digital server. 'Securing data at rest' means making sure that suitcase is inside a glass safe that only you have the combination for, even while it sits perfectly still on the bed. The glass sides aren't for decoration — they let you see your data is there, but nobody can reach in and grab the clothes (your information) without the correct code from you (your encryption key).

Now imagine you need to send a valuable necklace (a database backup) to your cousin in another city. You wouldn't just toss it in a cardboard box and drop it in the post, would you? Instead, you hire an armoured courier van with a lockbox inside. The van drives along a sealed highway (the secure network tunnel, like TLS). Even if someone stops the van, they cannot open the lockbox without the key. The necklace is your 'data in transit' — moving from one computer to another — and the armoured van and lockbox are the encryption and secure protocols that protect it while it moves.

The biggest mistake people make is thinking a normal lock on the hotel room door is enough. In the digital world, a simple password on your database is like a flimsy lock — it might stop a curious cleaner, but it won't stop a determined thief. The glass safe (Transparent Data Encryption) and the armoured courier (TLS/SSL) are the real protections you need for data at rest and in transit.

How It Actually Works

Let's start with the fundamental split: 'data at rest' is any information stored permanently on a disk, like the records inside a SQL Server database. 'Data in transit' is that same information when it's being sent over a network, for example, when your application queries the database and the results travel back as network packets.

For data at rest in Azure SQL Database or Azure SQL Managed Instance, the primary tool is Transparent Data Encryption (TDE). TDE automatically encrypts the data before it is written to the disk and decrypts it when it is read back into memory. The word 'transparent' is critical: your application and users do not notice it is happening. They connect as normal, run queries as normal, and the database engine handles the encryption behind the scenes. TDE uses a symmetric key called the Database Encryption Key (DEK), which itself is protected by a certificate or an asymmetric key stored in the master database of the server. In Azure, you can either let the platform manage this key (service-managed key) or take control yourself using a customer-managed key stored in Azure Key Vault. Azure Key Vault is a secure, cloud-based safe for secrets: passwords, certificates, and encryption keys. Using a customer-managed key means you can rotate (change) the key on your own schedule and even revoke access to the database if needed, effectively destroying the data by removing the key.

There is also a feature called Always Encrypted, which is different from TDE. Always Encrypted encrypts data in the client application *before* it ever reaches the database. The database never sees the unencrypted values. This means even a database administrator with full access to the server cannot read those encrypted columns. The encryption keys for Always Encrypted are stored in the client's key store or in Azure Key Vault. The exam will test you on when to use TDE versus Always Encrypted: TDE protects the whole database at rest on disk, while Always Encrypted protects specific sensitive columns from being seen by the database itself.

Now for data in transit. When a client application talks to an Azure SQL Database, the connection should always use Transport Layer Security (TLS). TLS is a protocol that encrypts the data as it leaves the client and decrypts it only when it arrives at the server. It also verifies the server's identity using certificates, so you know you're talking to the real database, not an impostor. Azure forces TLS 1.2 or higher for all connections; older versions like TLS 1.0 and 1.1 are deprecated. In the connection string of your application, you must set 'Encrypt=True' and 'TrustServerCertificate=False' to enforce TLS and validate the certificate. If you set TrustServerCertificate to True, you are telling the client to accept any certificate, which defeats the security because a man-in-the-middle attacker could present their own certificate and intercept your data.

Beyond TLS, there is Azure Virtual Network service endpoints and private endpoints. A service endpoint extends your virtual network to the SQL Database service over the Azure backbone network, keeping traffic off the public internet. A private endpoint gives your database a private IP address inside your virtual network, so traffic never leaves Microsoft's secure network. This is the gold standard for data in transit because it eliminates exposure to the public internet entirely.

The exam also expects you to know about firewall rules. Azure SQL has a server-level firewall and a database-level firewall. By default, all public access is blocked. You must explicitly allowlist client IP addresses or ranges. There is also the option to 'Allow Azure Services and resources to access this server', which is a broad setting that permits traffic from all Azure data centres. The exam frequently warns against leaving this on in production because it is too permissive.

Finally, let's tie it all together with key management. The keys that protect both data at rest (TDE keys) and data in transit (TLS certificates) should be rotated periodically. Azure Key Vault can automate key rotation. You should also enable auditing and monitoring to detect unauthorised access attempts. SQL Server provides 'SQL Audit' to log access to sensitive data, and Azure SQL Database has 'Advanced Data Security' which includes vulnerability assessment and threat detection.

Flow diagram showing how data moves from client to database, protected by TLS in transit and by TDE at rest, with Always Encrypted guarding sensitive columns.

Walk-Through

1

Enable TDE on the database

Execute the command ALTER DATABASE your_database SET ENCRYPTION ON. This encrypts the data at rest at the page level, using a Database Encryption Key (DEK) protected by the server's certificate or a key in Azure Key Vault.

2

Choose key management for TDE

Decide between service-managed keys (Azure handles key rotation) or customer-managed keys (you manage keys in Azure Key Vault). Customer-managed keys give you control but require more administrative overhead and proper granting of permissions to the SQL server managed identity.

3

Configure Always Encrypted for sensitive columns

Identify columns containing highly sensitive data (e.g., credit card numbers, Social Security numbers). Use the Always Encrypted wizard in SSMS or T-SQL to generate Column Master Keys (CMK) and Column Encryption Keys (CEK). Update the application connection string to include 'Column Encryption Setting=Enabled'.

4

Enforce TLS and certificate validation

In the application connection string, set Encrypt=True and TrustServerCertificate=False. This forces the client to validate the server's TLS certificate, preventing man-in-the-middle attacks. Ensure the application uses TLS 1.2 or higher.

5

Set up private endpoints or service endpoints

Create a private endpoint in the Azure portal for the SQL Database, assigning it a private IP address from your virtual network. Update DNS to resolve the server name to the private IP. For service endpoints, enable them on the subnet and add the virtual network rule to the SQL server firewall.

6

Configure firewall rules and disable broad access

Navigate to the SQL server 'Firewalls and virtual networks' blade. Disable 'Allow Azure Services and resources to access this server'. Add IP firewall rules for only the necessary client IP ranges. Consider adding database-level firewall rules for an extra layer of granularity.

What This Looks Like on the Job

Consider a medium-sized e-commerce company running an online store. Their Azure SQL Database holds customer names, addresses, and payment card details (though payment data should ideally be tokenized, this example assumes a misconfiguration). The company hires a new database administrator (you, for this scenario) to replace someone who left abruptly. You discover several serious security gaps.

First, you check data at rest. The old DBA never enabled TDE. That means if someone steals the physical disk backups or gains access to the underlying storage files, they can read all customer data in plain text. Your first action is to enable TDE on the database. In Azure, this is a toggle in the portal or a single ALTER DATABASE statement. You also decide to use a customer-managed key in Azure Key Vault, so you can rotate the key quarterly. You create a new key in Key Vault, grant the SQL Server managed identity access to it, and configure the database to use that key.

Next, data in transit. You examine the application's connection strings. They look like this:

Server=tcp:myserver.database.windows.net,1433;Initial Catalog=mydb;Persist Security Info=False;User ID=myuser;Password=mypassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;

You immediately spot the error: TrustServerCertificate is set to True. This means the application will accept any certificate the server presents, including a fake one from an attacker. You change it to False. You also notice the application is connecting over the public internet. The company has an Azure Virtual Network. You create a private endpoint for the SQL Database, which gives it a private IP address. Then you update the connection string to use that private IP or the private DNS zone name. Now traffic from the application servers stays entirely inside Microsoft's network, never touching the public internet.

Third, firewall rules. The old DBA had left 'Allow Azure Services and resources to access this server' enabled. This is a wide-open door. You disable it and instead add specific IP ranges for the company's application servers and your own jump box for administration. You also set up a database-level firewall for the most sensitive databases so that even if someone gains access to the server admin account, they still need to be on the correct IP to connect.

Finally, you set up auditing. You enable SQL Audit to log all SELECT statements on the table containing credit card numbers (though ideally that column would be encrypted with Always Encrypted or tokenized). You also enable Advanced Data Security to receive alerts when someone tries to brute-force the admin password or performs an unusual query pattern.

That is what a real-world DBA does daily: triaging misconfigurations, hardening connections, managing keys, and always thinking about how data looks when it's stored versus when it moves.

How DP-300 Actually Tests This

The DP-300 exam tests 'Secure data at rest and in transit' primarily through multiple-choice and multiple-select questions. Expect at least 4-6 questions on this domain. The exam writers love creating 'twin' questions where you must choose between TDE and Always Encrypted, or between service-managed keys and customer-managed keys.

Here are the specific exam topics you must memorise:

Transparent Data Encryption (TDE): Know the difference between service-managed and customer-managed (bring your own key, BYOK). Know that TDE encrypts the database at the page level, before it is written to disk. Know the command: ALTER DATABASE ... SET ENCRYPTION ON.

Always Encrypted: Know that it encrypts data in the client driver, so the database never sees plaintext. Know that it is used for highly sensitive columns like credit card numbers or national ID numbers. Know that the connection string must include 'Column Encryption Setting=Enabled'.

TLS and connection security: Know that 'Encrypt=True' and 'TrustServerCertificate=False' are the recommended settings. Know that Azure SQL Database rejects connections below TLS 1.2 by default.

Private endpoint / service endpoints: Know that private endpoints give a private IP and traffic stays on the Microsoft backbone. Know that service endpoints are simpler but less secure because they cannot be used to block all public access.

Firewall rules: Know the server-level firewall vs database-level firewall. Know the IP firewall rules and virtual network rules. Know that the default is 'deny all'. Know that 'Allow Azure Services' is a permissive setting not recommended for production.

Azure Key Vault: Know how to store TDE keys and Always Encrypted keys in Key Vault. Know the concept of key rotation and key revocation as a form of 'cryptographic shredding' (deleting the key makes the data permanently unreadable).

Common traps:

They give a scenario where data must be encrypted even from the DBA. The answer is Always Encrypted, not TDE, because TDE does not protect data from the database server itself.

They describe a connection string with TrustServerCertificate=True and ask what the vulnerability is. The correct answer is 'it allows man-in-the-middle attacks because the client does not validate the server certificate'.

They ask 'Which setting should you disable to improve security?' and list 'Allow Azure Services'. The answer is to disable it and use specific IP rules or private endpoints.

They give a scenario where the company needs to rotate the database encryption key every 30 days. The correct answer is 'use customer-managed keys in Azure Key Vault' because service-managed keys cannot be rotated on-demand by the customer.

Key definitions to memoize:

DEK: Database Encryption Key, used by TDE.

CEK: Column Encryption Key, used by Always Encrypted.

CMK: Customer-managed key, stored in Azure Key Vault.

SMK: Service-managed key, managed by Azure.

TLS: Transport Layer Security, the protocol that encrypts data in transit.

Private endpoint: A network interface that connects you privately to an Azure service.

Cryptographic shredding: Making data permanently unreadable by deleting the encryption key.

Key Takeaways

Transparent Data Encryption (TDE) encrypts data at rest automatically and transparently to the application, but it does not protect data from the database server itself.

Always Encrypted encrypts sensitive columns in the client driver, meaning the database never sees plaintext values, protecting data even from database administrators.

All connections to Azure SQL Database should use TLS 1.2 or higher with Encrypt=True and TrustServerCertificate=False in the connection string.

Private endpoints provide network isolation by giving the database a private IP address, but they do not replace the need for TLS encryption.

Customer-managed keys in Azure Key Vault let you control key rotation and revocation for TDE, enabling cryptographic shredding by deleting the key.

Disable 'Allow Azure Services and resources to access this server' in production and use specific IP firewall rules or virtual network rules instead.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Transparent Data Encryption (TDE)

Encrypts the entire database at rest on disk automatically.

Transparent to the application; no connection string changes needed.

The database engine can still see plaintext data in memory.

Uses a Database Encryption Key (DEK) stored on the server or in Key Vault.

Always Encrypted

Encrypts specific columns at the client side before data reaches the database.

Requires application changes: connection string must include 'Column Encryption Setting=Enabled'.

The database engine never sees plaintext values for encrypted columns.

Uses a Column Master Key (CMK) and Column Encryption Key (CEK) stored on the client or in Key Vault.

Service-Managed Key

Azure automatically rotates the key on a schedule.

You cannot control the rotation schedule or revoke the key.

No additional cost from Azure Key Vault for the key itself.

Customer-Managed Key (BYOK)

You control key rotation and can revoke access immediately.

You store the key in Azure Key Vault and pay for Key Vault operations.

Enables cryptographic shredding: deleting the key makes the data unreadable.

Service Endpoint

The database retains a public IP address; traffic uses Azure backbone but is not fully isolated.

Cannot block all public access; you add a firewall rule to allow the virtual network.

Free of charge; included with the virtual network.

Protects against internet-based threats but not against other Azure tenants.

Private Endpoint

The database gets a private IP address inside your virtual network; public access can be fully blocked.

You must manage private DNS zones to resolve the server name to the private IP.

Incur small costs per endpoint per month.

Protects against all external network threats; traffic is isolated to your virtual network.

Watch Out for These

Mistake

TDE and Always Encrypted are the same thing, just different names for encrypting the whole database.

Correct

TDE encrypts the whole database at rest on disk, but it does not protect data from the database server itself. Always Encrypted encrypts specific columns in the client application, so the database never sees the plaintext values.

The word 'encryption' is used broadly, so beginners assume any encryption feature is interchangeable. In reality, the two solve completely different threat models.

Mistake

If I enable TDE, all my data is automatically encrypted during transit to the application.

Correct

TDE only protects data at rest on disk. Data in transit between the application and the database is protected by TLS, a completely separate mechanism. You must configure both.

The name 'Transparent Data Encryption' sounds like it covers everything, so beginners assume it's a one-stop solution.

Mistake

A private endpoint means my data is automatically encrypted on the wire.

Correct

A private endpoint keeps traffic off the public internet, but does not encrypt the data itself. You still need TLS to encrypt the traffic. Private endpoint is about network isolation, not encryption.

People conflate 'private network' with 'encrypted'. A private network is more secure, but the data can still be sniffed if the network is compromised.

Mistake

Firewall rules alone are enough to secure data in transit.

Correct

Firewall rules control which IP addresses can connect, but they do not encrypt the traffic. An attacker who breaches the network can still read unencrypted data. You must combine firewalls with TLS.

Firewalls are a familiar concept from home Wi-Fi, so beginners over-rely on them and forget that encryption is the main protection.

Mistake

If I use a service-managed key for TDE, Azure can see my data.

Correct

Azure cannot see your data with service-managed keys. Microsoft's operations teams cannot access customer data. Service-managed keys are stored in secure enclaves that even Microsoft employees cannot access. However, you give up the ability to rotate keys on your own schedule.

There is a general fear of cloud providers having access to data, especially from on-premises security professionals. But Azure's architecture is designed to prevent that.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

Does enabling TDE slow down my database?

TDE adds a small overhead (typically 3-5% performance impact) because data must be decrypted when read from disk and encrypted when written. The impact is minimal for most workloads because the encryption is done by the SQL Server engine using hardware acceleration.

Can I use TDE and Always Encrypted together on the same database?

Yes, they are complementary. TDE protects all data at rest on disk, while Always Encrypted protects specific columns from being readable by the database server itself. You can enable both on the same database.

What happens if I lose my customer-managed key in Azure Key Vault?

If the key is deleted or you revoke access, the database becomes inaccessible. The data remains on disk but is permanently unreadable. This is called cryptographic shredding. You must keep backups of the key outside of Azure (e.g., in an on-premises HSM) to recover.

Do I need to change my application code to use TDE?

No, TDE is completely transparent to applications. The database handles all encryption and decryption automatically. The application connects as normal and sees plaintext data.

What is the difference between a service endpoint and a private endpoint?

A service endpoint extends your virtual network to the SQL service over the Azure backbone, but the database still has a public IP address. A private endpoint gives the database a private IP address inside your VNet, blocking all public access entirely.

How do I know which encryption key was used for TDE?

Run the query SELECT * FROM sys.dm_database_encryption_keys in the database. It shows the encryption state and the encryption key thumbprint. For the server-level certificate, use sys.certificates.

Terms Worth Knowing

Keep going

You've finished Securing Data at Rest and in Transit. Continue through the DP-300 study guide to build a complete picture of the exam.

Done with this chapter?