πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901 aws-aif-c01
Guided DP-420 Domain 5
Domain 5 β€” Module 4 of 7 57%
25 of 28 overall

DP-420 Study Guide

Domain 1: Design and Implement Data Models

  • Cosmos DB β€” The Big Picture Free
  • Designing Your Data Model Free
  • Partition Key Strategy Free
  • Synthetic and Hierarchical Partition Keys Free
  • Relationships β€” Embedding vs Referencing Free
  • SDK Connectivity and Client Configuration Free
  • SDK CRUD Operations and Transactions Free
  • SQL Queries in Cosmos DB Free
  • SDK Query Pagination and LINQ Free
  • Server-Side Programming Free
  • Transactions in Practice Free

Domain 2: Design and Implement Data Distribution

  • Global Replication and Failover
  • Consistency Levels: Five Choices, Real Trade-Offs
  • Multi-Region Writes and Conflict Resolution

Domain 3: Integrate and Move Data

  • Change Feed with Azure Functions and Processors
  • Analytical Workloads: Synapse Link and Fabric Mirroring
  • Data Movement: ADF, Kafka, and Spark Connectors

Domain 4: Optimize Query and Operation Performance

  • Indexing Policies: Range, Spatial, and Composite
  • Request Units and Query Cost Optimization
  • Integrated Cache and Dedicated Gateway
  • Change Feed Patterns: Materialized Views and Estimator

Domain 5: Maintain an Azure Cosmos DB Solution

  • Monitoring: Metrics, Logs, and Alerts
  • Backup and Restore: Periodic vs Continuous
  • Network Security: Firewalls, VNets, and Private Endpoints
  • Data Security: Encryption, Keys, and RBAC
  • Cost Optimization: Throughput Modes and RU Strategy
  • DevOps: Infrastructure as Code and Deployments
  • Exam Strategy and Cross-Domain Review

DP-420 Study Guide

Domain 1: Design and Implement Data Models

  • Cosmos DB β€” The Big Picture Free
  • Designing Your Data Model Free
  • Partition Key Strategy Free
  • Synthetic and Hierarchical Partition Keys Free
  • Relationships β€” Embedding vs Referencing Free
  • SDK Connectivity and Client Configuration Free
  • SDK CRUD Operations and Transactions Free
  • SQL Queries in Cosmos DB Free
  • SDK Query Pagination and LINQ Free
  • Server-Side Programming Free
  • Transactions in Practice Free

Domain 2: Design and Implement Data Distribution

  • Global Replication and Failover
  • Consistency Levels: Five Choices, Real Trade-Offs
  • Multi-Region Writes and Conflict Resolution

Domain 3: Integrate and Move Data

  • Change Feed with Azure Functions and Processors
  • Analytical Workloads: Synapse Link and Fabric Mirroring
  • Data Movement: ADF, Kafka, and Spark Connectors

Domain 4: Optimize Query and Operation Performance

  • Indexing Policies: Range, Spatial, and Composite
  • Request Units and Query Cost Optimization
  • Integrated Cache and Dedicated Gateway
  • Change Feed Patterns: Materialized Views and Estimator

Domain 5: Maintain an Azure Cosmos DB Solution

  • Monitoring: Metrics, Logs, and Alerts
  • Backup and Restore: Periodic vs Continuous
  • Network Security: Firewalls, VNets, and Private Endpoints
  • Data Security: Encryption, Keys, and RBAC
  • Cost Optimization: Throughput Modes and RU Strategy
  • DevOps: Infrastructure as Code and Deployments
  • Exam Strategy and Cross-Domain Review
Domain 5: Maintain an Azure Cosmos DB Solution Premium ⏱ ~16 min read

Data Security: Encryption, Keys, and RBAC

Protect Cosmos DB data with encryption at rest (service-managed and customer-managed keys), account keys, resource tokens, RBAC for data and management planes, and Always Encrypted for client-side protection.

Data security layers

β˜• Simple explanation

Think of data security in layers, like a bank vault. Encryption at rest is the vault walls β€” data is scrambled when stored. Keys are the combinations to the vault β€” you need one to get in. RBAC is the security guard checking your badge β€” different people get different levels of access. Always Encrypted is a locked briefcase inside the vault β€” even the bank staff can’t read what’s inside.

Cosmos DB provides multiple security layers:

  • Encryption at rest: Always on, transparent. Service-managed keys by default; customer-managed keys (CMK) for full control.
  • Authentication: Account keys (master keys), resource tokens (scoped), or Microsoft Entra ID (RBAC).
  • Authorisation: RBAC roles for data plane and management plane operations.
  • Client-side encryption: Always Encrypted protects sensitive fields end-to-end.

Marcus’s security checklist

βš™οΈ Marcus at FinSecure has SOC 2 requirements for data security:

  • All data encrypted at rest with customer-controlled keys
  • No shared master keys in application code
  • Least-privilege access for each microservice
  • PII fields (SSN, account numbers) encrypted client-side

Encryption at rest

Cosmos DB always encrypts data at rest β€” you cannot disable it.

AspectService-Managed Keys (default)Customer-Managed Keys (CMK)
Key managementMicrosoft manages keysYou manage keys in Azure Key Vault
Key rotationAutomatic by MicrosoftYou control rotation schedule
ComplianceMeets most requirementsRequired for some regulatory frameworks
SetupAutomatic β€” no configurationRequires Key Vault + managed identity
CostIncludedKey Vault charges apply
RevocationNot possibleRevoke access by removing key permissions
# Configure CMK with Azure Key Vault
az cosmosdb update --name finsecure-cosmos \
  --resource-group rg-finsecure \
  --key-uri "https://finsecure-vault.vault.azure.net/keys/cosmos-key/abc123"
πŸ’‘ Exam tip: CMK revocation

If you revoke the Key Vault permissions for a CMK-enabled Cosmos DB account, the account becomes inaccessible β€” all reads and writes fail. This is a powerful security control (you can lock out a compromised account) but also a risk (misconfigured Key Vault access can cause an outage).

The exam tests this: β€œWhat happens if the CMK is deleted from Key Vault?” β†’ the account becomes inaccessible.

Authentication methods

1. Account keys (master keys)

// Full access β€” read, write, delete anything
CosmosClient client = new CosmosClient(endpoint, accountKey);
  • Two keys: Primary and secondary (for rotation without downtime)
  • Full access: Master keys grant complete control β€” never embed in client apps
  • Rotation: Rotate using az cosmosdb keys regenerate; switch apps to the secondary key first

2. Resource tokens (scoped access)

// Create a permission that grants read access to a specific partition
Permission permission = await user.CreatePermissionAsync(
    new PermissionProperties(
        id: "readOrders",
        permissionMode: PermissionMode.Read,
        container: ordersContainer,
        resourcePartitionKey: new PartitionKey("customer-123")
    ),
    tokenExpiry: 3600  // 1 hour
);

string resourceToken = permission.Resource.Token;
// Give this token to the client β€” they can only read customer-123's orders
CosmosClient scopedClient = new CosmosClient(endpoint, resourceToken);
  • Scoped: Limit access to specific containers, partitions, or documents
  • Temporary: Tokens expire (1-24 hours, default 1 hour)
  • Per-user: Created via the Users and Permissions system

3. Microsoft Entra ID (RBAC)

The recommended approach β€” no keys or tokens to manage:

# Assign the built-in "Cosmos DB Built-in Data Reader" role
az cosmosdb sql role assignment create \
  --account-name finsecure-cosmos \
  --resource-group rg-finsecure \
  --role-definition-name "Cosmos DB Built-in Data Reader" \
  --principal-id "00000000-0000-0000-0000-000000000000" \
  --scope "/dbs/orders/colls/transactions"

RBAC: data plane vs management plane

AspectData Plane RBACManagement Plane RBAC
What it controlsRead/write/query operations on dataAccount config, databases, containers
RolesCosmos DB Built-in Data Reader, Data ContributorAzure built-in roles (Contributor, Reader)
ScopeAccount, database, container, or partitionSubscription, resource group, or account
AuthenticationMicrosoft Entra ID tokensMicrosoft Entra ID tokens
Key operationsCRUD on items, run queriesCreate/delete DBs, change throughput
Built-in Data Plane RolePermissions
Cosmos DB Built-in Data ReaderRead items, execute queries
Cosmos DB Built-in Data ContributorRead + write items, execute queries
πŸ’‘ Exam tip: RBAC vs master keys

RBAC with Microsoft Entra ID is the recommended authentication method for production. Master keys should only be used for initial setup or legacy applications. Key advantages of RBAC:

  • No secrets to rotate or leak
  • Least-privilege access (specific roles, scoped to containers)
  • Integration with Entra ID Conditional Access policies
  • Audit trail in Entra ID logs

The exam often presents β€œa developer has the master key in their code” as a security anti-pattern, with RBAC as the correct alternative.

Always Encrypted (client-side)

For the most sensitive data, Always Encrypted provides client-side encryption:

  • Data is encrypted before it leaves the application
  • Cosmos DB stores and indexes ciphertext β€” it never sees plaintext
  • Only the application with the encryption key can decrypt
  • Supports deterministic encryption (allows equality queries on encrypted fields) and randomised encryption (no queries, maximum security)
// Always Encrypted configuration
ClientEncryptionPolicy encryptionPolicy = new ClientEncryptionPolicy(
    new List<ClientEncryptionIncludedPath>
    {
        new ClientEncryptionIncludedPath
        {
            Path = "/ssn",
            ClientEncryptionKeyId = "customer-dek",
            EncryptionType = EncryptionType.Deterministic.ToString(),
            EncryptionAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA256"
        }
    }
);

Diana’s tip: πŸ” Diana requires Always Encrypted for SSN and account number fields β€” even FinSecure’s DBAs cannot see plaintext values.

🎬 Video walkthrough

🎬 Video coming soon

Data Security β€” DP-420 Module 25

Data Security β€” DP-420 Module 25

~16 min

Flashcards

Question

Can you disable encryption at rest in Cosmos DB?

Click or press Enter to reveal answer

Answer

No β€” encryption at rest is ALWAYS enabled and cannot be disabled. By default, Microsoft manages the keys. You can optionally use Customer-Managed Keys (CMK) via Azure Key Vault for full control.

Click to flip back

Question

What happens if you revoke Key Vault access for a CMK-enabled Cosmos DB account?

Click or press Enter to reveal answer

Answer

The account becomes completely inaccessible β€” all reads and writes fail. This is by design (security control) but also a risk if misconfigured. Restoring Key Vault access restores database access.

Click to flip back

Question

What are the two built-in data plane RBAC roles?

Click or press Enter to reveal answer

Answer

1) Cosmos DB Built-in Data Reader β€” read items and execute queries. 2) Cosmos DB Built-in Data Contributor β€” read, write, and execute queries. Both can be scoped to account, database, or container level.

Click to flip back

Question

How do resource tokens differ from master keys?

Click or press Enter to reveal answer

Answer

Resource tokens are scoped (specific container/partition), temporary (1-24 hours), and per-user. Master keys grant full, unrestricted access to everything in the account. Resource tokens are safer for client apps.

Click to flip back

Question

What does Always Encrypted protect against?

Click or press Enter to reveal answer

Answer

It protects against server-side data exposure β€” data is encrypted client-side before being sent to Cosmos DB. Even Microsoft and DBAs cannot see plaintext. It uses Azure Key Vault for key management and supports deterministic (queryable) and randomised (maximum security) encryption.

Click to flip back

Knowledge Check

Knowledge Check

Marcus needs to ensure that even FinSecure's database administrators cannot see customer SSN values stored in Cosmos DB. What should he implement?

Knowledge Check

A developer embeds the Cosmos DB master key in their web application's client-side JavaScript. What's the security risk and recommended fix?

Knowledge Check

Marcus needs to rotate the Cosmos DB master key without downtime. What's the correct process?


Next up: Cost Optimization β€” choosing between serverless, provisioned, and autoscale throughput to balance performance and cost.

← Previous

Network Security: Firewalls, VNets, and Private Endpoints

Next β†’

Cost Optimization: Throughput Modes and RU Strategy

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.