Security for a data platform is a chain of layers, and an attacker only needs one of them to fail. A perfectly encrypted storage account is still exposed if the pipeline authenticates with a connection string pasted into a notebook, and strong identity is worthless if the same account is reachable over the public internet from anywhere.
This lesson works through the layers in the order you would apply them, so you can defend each decision in an interview or an architecture review:
- Remove long-lived credentials from pipelines and configuration.
- Decide when customer-managed keys are actually required.
- Close public network paths without breaking the tools that need them.
- Choose encryption and logging settings that satisfy a real control.
Prerequisites
- !Azure RBAC role assignments
- !Storage accounts and containers
- !Bicep or ARM template basics
Start with a threat model, not a checklist
Controls applied without a threat model produce strange results: teams encrypt everything with expensive HSM keys while leaving a storage container open to anonymous access. Begin by listing what you are protecting, from whom, and what a successful attack would cost. For most data engineering estates the answer is similar: sensitive rows in the lake, credentials that unlock pipelines, and the ability to alter or delete data silently.
Then map realistic attack paths. A stolen personal access token in a laptop history file, a compromised service principal with broad rights, an over-permissive network path to a development account that holds a copy of production data. Each path suggests a specific control, and the control is easier to justify when tied to a scenario rather than to a generic best-practice list.
| Layer | Primary control | Failure it prevents | Common gap |
|---|---|---|---|
| Identity | Managed identities and least privilege | Stolen connection strings | Secrets still hardcoded in notebooks |
| Network | Private endpoints and firewall rules | Public exposure of raw data | Development accounts left open |
| Encryption | Platform or customer-managed keys | Offline disk theft, regulatory breach | Keys never rotated |
| Application | TLS 1.2 or above | Credential interception | Downgrade allowed for old clients |
| Detection | Diagnostic logs and alerts | Silent exfiltration or tampering | Logs collected but never queried |
Identity: prefer managed identities everywhere
A managed identity is an identity Azure manages and rotates for you. Pipelines, Databricks, Synapse, and Functions present that identity to services such as Key Vault without ever storing a secret, which removes the most common source of credential leakage in data teams.
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential(exclude_interactive_browser_credential=True)
client = SecretClient(
vault_url="https://kv-dataengineering.vault.azure.net/",
credential=credential,
)
client.set_secret("synapse-sql-connection", "Server=tcp:syn-prod.sql.azuresynapse.net,1433;Authentication=Active Directory Integrated;")
secret = client.get_secret("synapse-sql-connection")
print(f"loaded secret '{secret.name}' version {secret.properties.version}")
DefaultAzureCredential walks a chain of sources, so the same code works locally with your developer login and in Azure with the system-assigned identity. Assign roles at the narrowest scope: a pipeline that only reads one container should get Storage Blob Data Reader on that container, not Contributor on the account. Review assignments on a schedule, because accumulated rights are how a low-privilege service quietly becomes privileged.
Keys: platform-managed versus customer-managed
By default Azure encrypts storage with Microsoft-managed keys, which covers the standard threat of disk theft and satisfies many baselines with no work from you. Customer-managed keys stored in Key Vault add control and evidence: you choose the key, its rotation policy, and you can revoke it.
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: 'stadls001'
location: location
kind: 'StorageV2'
sku: { name: 'Standard_LRS' }
properties: {
isHnsEnabled: true
supportsHttpsTrafficOnly: true
minimumTlsVersion: 'TLS1_2'
allowBlobPublicAccess: false
encryption: {
services: { blob: { enabled: true, keyType: 'Account' } }
keySource: 'Microsoft.Keyvault'
keyVaultProperties: {
keyName: 'cmk-adls'
keyVaultUri: 'https://kv-dataengineering.vault.azure.net/'
}
}
}
}
Two operational costs come with that control. The storage account needs a managed identity with wrap and unwrap rights on the key, and if the key becomes unavailable, writes fail. Enable soft delete and purge protection on the vault so a deleted key cannot be permanently destroyed before recovery, and keep a documented break-glass procedure. Use customer-managed keys where a regulation or contract demands key custody, and skip them where it does not.
Network isolation that does not break your tooling
Private endpoints give storage, Key Vault, and Synapse a private IP address inside your virtual network, and a private DNS zone makes name resolution work transparently. Public access can then be disabled outright, which removes the entire class of attacks that rely on a reachable endpoint.
The practical complications are connectivity for everything else: Azure DevOps agents, Purview scans, Databricks, and engineers on laptops all need a route. Purview supports managed identity authentication plus firewall rules for scanning private accounts, so plan that integration rather than opening a public path as a shortcut. Development accounts deserve the same treatment as production, since they usually contain copies of real data.
Encryption in transit and the logging that proves it
Enforce TLS 1.2 as the minimum on storage and refuse HTTP traffic. This is a single property in the account configuration, and it is one of the first things an auditor asks to see. Pair it with disabling anonymous blob access so a misconfigured SAS link cannot expose a container.
Detection is the layer people defer. Enable diagnostic settings on storage, Key Vault, Purview, and the data factory, send them to a Log Analytics workspace, and query for unusual read volumes on sensitive paths. An alert on a spike in anonymous failures or a new identity reading a container it has never touched is worth more than another policy document, because it gives you time to respond while the incident is still small.
Securing the pipeline layer itself
Storage and network controls mean little if the orchestration layer is loose. Give each data factory a system-assigned identity and grant that identity exactly the roles its activities need, so a compromised pipeline cannot reach unrelated subscriptions. Linked services should reference Key Vault rather than embedding credentials, which keeps connection details out of the JSON that developers export and paste.
Databricks needs its own treatment. Store secrets in a secret scope backed by Key Vault, never in notebooks or cluster configuration fields that persist in plain text, and restrict cluster creation to a known set of VM images. Keep development workspaces on a separate subscription or at least a separate resource group so an experiment cannot attach to production storage.
Finally, review who can publish to the production factory. Contributor rights on the factory effectively grant the ability to change where data flows, so production publish should be reachable only through the pipeline that validates a pull request. That single control converts code review from a courtesy into a gate.
The controls worth automating first
Once the design is agreed, encode it so drift becomes visible. Azure Policy can deny storage accounts that allow public blob access, that accept older than TLS 1.2, or that are created outside an approved region. A definition that blocks the non-compliant resource at creation time prevents the problem rather than reporting it later.
resource storagePolicy 'Microsoft.Authorization/policyDefinitions@2021-06-01' = {
name: 'deny-insecure-storage'
properties: {
mode: 'Indexed'
policyRule: {
if: {
allOf: [
{ equals: 'Microsoft.Storage/storageAccounts'
field: 'type' }
{ notEquals: 'TLS1_2'
field: 'Microsoft.Storage/storageAccounts/minimumTlsVersion' }
]
}
then: { effect: 'deny' }
}
}
}
Assign the policy at the management group level so new subscriptions inherit it, and start in audit mode for one quarter before switching to deny. Audit mode gives you the list of existing non-compliant accounts, which is the actual migration work, without surprising a team mid-deployment.
Common Mistakes
Storing connection strings in notebooks or pipeline parameters
Fix: Reference Key Vault from the pipeline and authenticate with a managed identity.
Granting Contributor on the storage account to every data engineer
Fix: Scope data roles such as Storage Blob Data Reader or Contributor to the containers that need them.
Enabling customer-managed keys without a recovery procedure
Fix: Configure soft delete and purge protection, grant wrap and unwrap rights, and document break-glass steps.
Collecting logs no one queries
Fix: Pair every diagnostic setting with a saved query and an alert threshold tied to a named owner.
Best Practices
- Remove long-lived credentials before adding any new control
- Keep private endpoints and private DNS zones in the same deployment as the resource
- Set minimum TLS version and disable public blob access at account creation
- Rotate keys on a schedule and verify rotation with an automated check
- Review identity assignments quarterly against a current ownership list
Questions interviewers ask about data security
đ¯Interview Tip
Expect a question that forces a trade-off, such as disabling public access while Purview still needs to scan. Answer with the mechanism: managed identity authentication plus firewall rules and a private endpoint for the scan, rather than a temporary public exception.
Interview Questions
Q1: Why are managed identities preferred over service principals with secrets?
Azure creates and rotates the credentials for you, so there is no secret in configuration to leak, expire, or hardcode. Access is then controlled purely through RBAC, which is auditable and revocable in one place.
Q2: When do you need customer-managed keys?
When a regulation, contract, or internal control requires you to hold and rotate the encryption key yourself, or when you need the ability to revoke access by destroying a key. For other workloads Microsoft-managed keys are simpler and equally strong cryptographically.
Q3: Explain the difference between RBAC and ACLs on a data lake.
RBAC assigns roles at the resource or container level through Azure's authorization plane. ACLs are POSIX-style permissions applied to individual directories and files inside the lake. Use RBAC by default and ACLs for rare per-directory exceptions.
Q4: How would you prove to an auditor that access controls work?
Show the version-controlled role assignments, a Log Analytics query demonstrating which identity accessed which path over a period, and the alert rules that fire on unexpected access. Evidence over time is stronger than a screenshot of a configuration blade.
Key Takeaways
- Threat model first so each control maps to a real attack path
- Managed identities eliminate the credential-leakage class of incidents
- Customer-managed keys add custody and cost, not stronger cryptography
- Private endpoints plus private DNS close public paths without breaking services
- TLS 1.2 minimum and disabled public blob access are one-line wins
- Diagnostic logs only help if a saved query and an owner exist