Domain 2 of 3 · Chapter 1 of 4

Implement database security controls

Unlock the complete study guide + 25 practice exams totaling 1,500 questions.

Bundled into the existing Building AI Applications with Azure Cosmos DB premium course — no separate purchase.

14-day refund guarantee on one-time purchases and your first subscription charge.

Included in this chapter:

  • Four controls between a request and your data
  • Three credentials for the data plane
  • Connecting with a managed identity
  • Turning off account key authentication
  • Rotating account keys without downtime
  • Delegating access with resource tokens
  • Building the REST authorization header
  • Data actions and the built-in data roles
  • Creating, assigning, and scoping data roles
  • Control-plane roles for administrators
  • Making configuration changes attributable
  • Choosing among the network controls
  • Configuring the IP firewall
  • Admitting subnets through service endpoints
  • Moving a subnet from IP rules to a service endpoint
  • Connecting privately with Azure Private Link
  • Resolving the account name to private addresses
  • Adding a private endpoint to a live account
  • Enabling dynamic data masking
  • Writing a masking policy
  • Granting unmasked access
  • What masking does not protect
  • Recognizing security scenarios in exam questions

IP firewall vs service endpoint vs private endpoint

Network controlIP firewallService endpointPrivate endpoint
What the account admitsPublic IP addresses or CIDR ranges (no private addresses)A subnet's identity, matched by a virtual network ruleTraffic arriving through the private endpoint
Address the client connects toThe account's public addressThe account's public address (DNS is unchanged)Private IP addresses in your subnet: one global, one per account region
Other networks that can use itAny source whose public IP is listedOnly subnets added to the account; peered networks need their own rulesPeered virtual networks and on-premises over VPN or ExpressRoute private peering
Settings to configureipRules (ipRangeFilter before API version 2020-04-01)Microsoft.AzureCosmosDB on the subnet plus a virtual network rule on the accountSql or SqlDedicated subresource plus a private DNS zone
Direct mode TCP ports to open10000 to 2000010000 to 200000 to 65535

Decision tree

Private addresses only,no public path?YesNoPrivate endpoint,publicNetworkAccess= DisabledClients in Azurevirtual networksubnets?YesNoService endpoint+ virtual networkruleClients have fixedpublic IPs?YesNoIP firewall rules(public IPs, CIDR)Azure serviceswithout fixed IPs?YesNoIP firewall: Acceptconnections fromwithin Azuredatacenters(all of Azure,last resort)Private endpointover VPN orExpressRouteprivate peering

Cheat sheet

  • Managed identity authentication removes application-held database secrets
  • disableLocalAuth enforces migration away from account key authentication
  • Rotate the unused key before switching applications and regenerating the active key
  • Safe key rotation blocks regeneration of a key used within the last twelve hours
  • Resource tokens delegate limited access without distributing an account key
  • Resource tokens expire after one hour by default and can last at most five hours
  • Permission resources distinguish read-only access from read-write-delete access
  • A user can have only one permission for a particular resource
  • REST authorization wraps the selected credential in an encoded token string
  • A REST master-token signature is bound to the request method, resource, and date
  • Reading a permission issues a fresh resource token
  • Cosmos DB Built-in Data Reader grants reads and queries without item writes
  • Cosmos DB Built-in Data Contributor authorizes container data operations and item mutations
  • Container-scoped assignments restrict a data role to one container
  • Every SDK data-access role needs the readMetadata action
  • SDK queries require both executeQuery and readChangeFeed permissions
  • Native data-plane custom roles do not support notDataActions
  • Native role definitions and assignments use the cosmosdb sql role command family
  • Item reads and container query execution are separate native data actions
  • Cosmos DB Operator manages accounts without access to data or account keys
  • Managing native data-plane roles requires control-plane permissions
  • Disabling key-based metadata writes moves resource changes to attributable management operations
  • ControlPlaneRequests captures configuration operations rather than item traffic
  • Correlating control-plane diagnostics with the Activity log identifies the caller
  • Passing a Cosmos DB network rule does not grant database authorization
  • IP firewall rules admit public addresses or CIDR ranges rather than private subnet addresses
  • Service endpoint access needs both subnet enablement and a Cosmos DB virtual network rule
  • Enabling a service endpoint changes how Cosmos DB identifies the request source
  • Cross-subscription service endpoint access still requires a common tenant and provider registration
  • Virtual network peering does not inherit a service endpoint allowlist entry
  • The Azure datacenter exception is not restricted to your own subscription
  • Disabling public network access overrides public-source firewall exceptions
  • Firewall and service endpoint rule changes can need fifteen minutes to propagate
  • Portal data browsing must pass the Cosmos DB account firewall
  • Stage the account's subnet rule before enabling the subnet service endpoint
  • Account updates revalidate access to configured service-endpoint subnets
  • Network-rule collection updates must include every admission that should remain
  • Cosmos DB network ACLs filter requests rather than rejecting the connection itself
  • Private endpoints provide private-IP connectivity from connected networks and on-premises
  • NoSQL private endpoints use the Sql subresource and privatelink.documents.azure.com zone
  • A Cosmos DB private endpoint needs global and per-region private addresses
  • Private DNS zone groups maintain Cosmos DB regional records automatically
  • Private Link Direct mode needs the full TCP port range
  • One Cosmos DB account supports at most two hundred private endpoints
  • Client DNS resolution determines whether the account hostname uses Private Link
  • Explicit client allow rules avoid the default interruption when adding a private endpoint
  • Automatic private endpoint approval requires an approval action on the Cosmos DB account
  • A rejected Cosmos DB private endpoint connection must be recreated
  • Dynamic data masking is enabled at the account and configured on containers
  • The default masking strategy depends on the value's type
  • MaskSubstring masks a specified forward range within a string
  • Email masking preserves the first username letter and the domain ending
  • Masking exclusions require an include-all root rule
  • Masking paths address fields in all array elements rather than a numbered element
  • Dynamic data masking requires Microsoft Entra identity authentication rather than account keys
  • Unmasked reads require the unmask data action and ordinary read permissions
  • Dynamic data masking limits read projections but does not encrypt stored data
  • Write operations can expose unmasked values even when reads are masked
  • Change feed access on a masked account requires unmask permission
  • Masking adds processing only when returned data needs masking
  • Masking does not replace restrictions on direct database access
  • Masking the item ID or partition key prevents the Data Explorer document view

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-firewall
  2. https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/dp-420
  3. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/dynamic-data-masking
  4. https://learn.microsoft.com/en-us/azure/cosmos-db/reference-data-plane-security
  5. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-connect-role-based-access-control
  6. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/security
  7. https://learn.microsoft.com/en-us/rest/api/cosmos-db/access-control-on-cosmosdb-resources
  8. https://learn.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredential
  9. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-rotate-keys
  10. https://learn.microsoft.com/en-us/azure/cosmos-db/audit-control-plane-logs
  11. https://learn.microsoft.com/en-us/rest/api/cosmos-db/permissions
  12. https://learn.microsoft.com/en-us/rest/api/cosmos-db/create-a-permission
  13. https://learn.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/sql-resources/create-update-sql-role-definition
  14. https://learn.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/database-accounts/list-read-only-keys
  15. https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/databases
  16. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-private-endpoints
  17. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-vnet-service-endpoint
  18. https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-service-endpoints-overview
  19. https://learn.microsoft.com/en-us/azure/cosmos-db/dedicated-gateway
  20. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/sdk-connection-modes
  21. https://learn.microsoft.com/en-us/azure/expressroute/expressroute-circuit-peerings
  22. https://learn.microsoft.com/en-us/azure/cosmos-db/analytical-store-introduction
  23. https://learn.microsoft.com/en-us/azure/cosmos-db/analytical-store-private-endpoints
  24. https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-overview
  25. https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns-integration
  26. https://learn.microsoft.com/en-us/azure/firewall/dns-settings
  27. https://learn.microsoft.com/en-us/azure/dns/dns-private-resolver-overview
  28. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-manage-indexing-policy
  29. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-always-encrypted