Secure model endpoints, including Managed Identity (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Secure model endpoints, including Managed Identity


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

As organizations increasingly integrate Artificial Intelligence (AI) into database applications, protecting AI model endpoints has become a critical security requirement. AI-enabled SQL applications frequently invoke external AI services such as Azure OpenAI, Azure AI Foundry models, Azure AI Search, Azure Machine Learning endpoints, and custom REST APIs. These services often process sensitive business data, making endpoint security an important aspect of application architecture.

The DP-800 certification expects candidates to understand how to securely authenticate applications to AI services without exposing secrets. Microsoft recommends using Microsoft Entra ID (formerly Azure Active Directory) and Managed Identities whenever possible instead of storing passwords or API keys.

A major focus of the exam is understanding how SQL applications securely communicate with external AI services while following the Zero Trust security model.


Why AI Model Endpoints Must Be Secured

An AI model endpoint is the network endpoint that applications call to perform AI operations such as:

  • Text generation
  • Embedding generation
  • Semantic search
  • Retrieval-Augmented Generation (RAG)
  • Classification
  • Summarization
  • Vector similarity searches

Because endpoint requests frequently contain:

  • Customer information
  • Financial records
  • Healthcare data
  • Intellectual property
  • Confidential business documents

Unauthorized access can lead to:

  • Data leakage
  • Unauthorized AI usage
  • Excessive Azure costs
  • Compliance violations
  • Prompt injection attacks
  • Credential theft

Therefore, authentication and authorization are essential.


Authentication Options for AI Endpoints

Microsoft AI services generally support multiple authentication mechanisms.

Authentication MethodRecommendedNotes
API KeysGoodSimple but secrets must be managed
Microsoft Entra IDExcellentPreferred for enterprise environments
Managed IdentityBestEliminates secret management
Service PrincipalsVery GoodUsed for applications outside Azure
OAuth TokensGoodShort-lived secure tokens

For DP-800, Managed Identity is the preferred authentication method whenever available.


Understanding Managed Identity

A Managed Identity is an automatically managed identity in Microsoft Entra ID that Azure creates for an Azure resource.

Instead of storing:

  • passwords
  • connection strings
  • API keys
  • client secrets

the Azure platform authenticates on behalf of the application.

Examples of Azure resources supporting Managed Identity include:

  • Azure SQL Database
  • Azure SQL Managed Instance
  • Azure App Service
  • Azure Functions
  • Azure Container Apps
  • Azure Kubernetes Service
  • Azure Virtual Machines
  • Azure Data Factory
  • Azure Logic Apps
  • Azure Machine Learning

Types of Managed Identity

There are two types.

System-Assigned Managed Identity

Characteristics:

  • Created automatically
  • One identity per Azure resource
  • Deleted automatically with the resource
  • Cannot be shared

Example:

Azure Function → One Managed Identity

If the Function App is deleted:

Identity is deleted automatically.


User-Assigned Managed Identity

Characteristics:

  • Independent Azure resource
  • Can be assigned to multiple services
  • Exists after applications are deleted
  • Easier to reuse across environments

Example:

One User-Assigned Identity may be used by:

  • Azure Function
  • Azure App Service
  • Azure SQL Managed Instance
  • Azure Container App

This simplifies permission management.


Benefits of Managed Identity

Managed Identity provides several important advantages.

No Secret Management

Developers no longer store:

  • passwords
  • API keys
  • client secrets
  • certificates

This significantly reduces security risks.


Automatic Credential Rotation

Azure rotates credentials automatically.

Developers never need to:

  • renew certificates
  • rotate passwords
  • update connection strings

Reduced Attack Surface

Secrets stored in:

  • source code
  • configuration files
  • GitHub repositories
  • CI/CD pipelines

are eliminated.


Improved Compliance

Managed Identity helps organizations meet:

  • SOC
  • ISO
  • HIPAA
  • GDPR
  • PCI DSS

security recommendations.


Fine-Grained Access Control

Permissions are assigned through Azure Role-Based Access Control (RBAC).

Applications receive only the permissions they require.


Authentication Flow Using Managed Identity

A typical authentication sequence is:

  1. Azure resource requests an access token.
  2. Azure Instance Metadata Service validates the request.
  3. Microsoft Entra ID issues an OAuth access token.
  4. Application sends the token to the AI endpoint.
  5. Azure AI service validates the token.
  6. Request is processed.

No passwords or API keys are exchanged.


Using Managed Identity with Azure OpenAI

Instead of:

API Key

Applications can authenticate using:

Bearer Token

obtained through Managed Identity.

The application requests an OAuth token for the Azure OpenAI resource and includes it in the HTTP Authorization header.

Advantages include:

  • no API key storage
  • centralized identity management
  • automatic credential rotation
  • Azure RBAC integration

Managed Identity with Azure AI Search

Azure AI Search supports Microsoft Entra authentication.

Applications using Managed Identity can:

  • create indexes
  • query indexes
  • update indexes
  • execute semantic search
  • perform vector search

Access permissions are controlled using Azure RBAC rather than shared administrative keys.


Managed Identity with Azure SQL Database

SQL applications may access AI services.

Example workflow:

Azure SQL Stored Procedure

External Application

Managed Identity

Azure OpenAI

Generated Response

No API keys are embedded anywhere.


Securing Azure AI Foundry Models

Azure AI Foundry endpoints also support Microsoft Entra authentication.

Best practices include:

  • Disable anonymous access.
  • Use Managed Identity where supported.
  • Restrict endpoint access with RBAC.
  • Enable private networking.
  • Monitor endpoint usage.
  • Enable diagnostic logging.

Azure Role-Based Access Control (RBAC)

Authentication identifies who is making the request.

Authorization determines what they can do.

Azure RBAC assigns permissions using roles.

Common roles include:

  • Cognitive Services User
  • Cognitive Services Contributor
  • Search Service Contributor
  • Search Index Data Reader
  • Search Index Data Contributor

Assign the minimum permissions required.


Principle of Least Privilege

Applications should receive only the permissions necessary to perform their tasks.

For example:

Application that generates embeddings:

Needs:

  • Generate embeddings

Does NOT need:

  • Delete deployment
  • Create deployments
  • Manage subscriptions

This reduces the impact of compromised credentials.


Private Endpoints

Many Azure AI services support Azure Private Link.

Benefits include:

  • Private IP addresses
  • No public internet exposure
  • Reduced attack surface
  • Simplified firewall rules
  • Secure communication within Azure Virtual Networks

Private Endpoints are strongly recommended for production deployments handling sensitive data.


Network Security

Additional protections include:

  • Azure Firewall
  • Network Security Groups
  • IP restrictions
  • Virtual Networks
  • Private DNS Zones
  • Azure DDoS Protection

These layers complement identity-based security.


Monitoring AI Endpoint Usage

Organizations should continuously monitor:

  • Authentication failures
  • Unauthorized access attempts
  • High request volumes
  • Geographic anomalies
  • Excessive token usage
  • API throttling
  • Unusual costs

Useful monitoring services include:

  • Azure Monitor
  • Azure Activity Log
  • Azure Log Analytics
  • Microsoft Defender for Cloud
  • Microsoft Sentinel

Secure Secrets That Cannot Be Eliminated

Some scenarios still require secrets.

Store them in:

  • Azure Key Vault

Never store secrets in:

  • source code
  • Git repositories
  • application settings
  • SQL tables
  • configuration files

Common Security Mistakes

Avoid:

  • Hardcoding API keys
  • Sharing one API key among multiple applications
  • Granting Contributor rights unnecessarily
  • Disabling authentication
  • Using long-lived secrets
  • Storing credentials in GitHub
  • Ignoring endpoint monitoring
  • Using public endpoints for sensitive workloads

DP-800 Exam Tips

Remember these key points:

  • Managed Identity is Microsoft’s preferred authentication mechanism for Azure-hosted applications.
  • Managed Identity eliminates the need to store secrets.
  • Microsoft Entra ID provides identity and authentication.
  • Azure RBAC provides authorization.
  • Use Private Endpoints for production AI workloads whenever possible.
  • Follow the Principle of Least Privilege.
  • Monitor AI endpoint activity using Azure Monitor and Microsoft Sentinel.
  • Store unavoidable secrets in Azure Key Vault.
  • Prefer token-based authentication over API keys.

Practice Exam Questions

Question 1

A development team wants an Azure Function to securely access an Azure OpenAI endpoint without storing credentials. Which authentication method should be recommended?

A. SQL Authentication

B. API Key stored in configuration

C. System-assigned Managed Identity

D. Windows Authentication

Answer: C

Explanation:
A system-assigned Managed Identity allows the Azure Function to authenticate with Microsoft Entra ID without storing credentials. This is Microsoft’s recommended approach for Azure-hosted services.


Question 2

Which statement best describes Microsoft Entra ID in relation to AI endpoints?

A. It encrypts AI model outputs.

B. It provides identity and authentication services.

C. It compresses prompt data.

D. It performs semantic search.

Answer: B

Explanation:
Microsoft Entra ID authenticates users, services, and applications, issuing access tokens that AI services validate before granting access.


Question 3

Which Azure feature automatically rotates credentials used by applications?

A. Azure Firewall

B. Azure Key Vault

C. Private Endpoint

D. Managed Identity

Answer: D

Explanation:
Managed Identity automatically manages and rotates credentials, eliminating manual secret rotation.


Question 4

Which Azure service should be used to securely store secrets when Managed Identity cannot be used?

A. Azure Blob Storage

B. Azure Files

C. Azure Key Vault

D. Azure Monitor

Answer: C

Explanation:
Azure Key Vault securely stores secrets, certificates, and keys, making it the preferred repository for credentials that cannot be eliminated.


Question 5

What is the primary purpose of Azure RBAC?

A. Encrypt data at rest

B. Assign authorization permissions to authenticated identities

C. Compress AI embeddings

D. Improve query performance

Answer: B

Explanation:
Azure RBAC controls which actions authenticated users, applications, and services can perform on Azure resources.


Question 6

An organization wants AI model traffic to remain entirely within its Azure virtual network. Which feature should be implemented?

A. API Management

B. Azure CDN

C. Private Endpoint

D. Azure Backup

Answer: C

Explanation:
Private Endpoints expose Azure services through private IP addresses within a virtual network, preventing traffic from traversing the public internet.


Question 7

Which authentication approach most reduces the risk of credential exposure?

A. Hard-coded API keys

B. Shared service accounts

C. Managed Identity

D. SQL logins

Answer: C

Explanation:
Managed Identity removes the need to store credentials in application code or configuration, significantly reducing the attack surface.


Question 8

What security principle recommends granting only the permissions an application requires?

A. Defense in Depth

B. Zero Downtime

C. Fail Fast

D. Principle of Least Privilege

Answer: D

Explanation:
The Principle of Least Privilege minimizes security risks by limiting permissions to only those necessary for a specific task.


Question 9

Which service is most appropriate for monitoring authentication failures and unusual AI endpoint activity?

A. Azure Monitor

B. Azure DNS

C. Azure Bastion

D. Azure Disk Storage

Answer: A

Explanation:
Azure Monitor collects logs, metrics, and alerts that help detect authentication failures, unusual access patterns, and operational issues affecting AI services.


Question 10

A company currently authenticates to Azure OpenAI using API keys embedded in application configuration files. What is the best modernization recommendation?

A. Store the API key in a SQL table.

B. Replace API keys with Managed Identity authentication whenever supported.

C. Increase the API key expiration period.

D. Share a single API key across all applications.

Answer: B

Explanation:
Replacing API keys with Managed Identity improves security by eliminating stored secrets, enabling automatic credential management, and integrating with Microsoft Entra ID and Azure RBAC.


Go to the DP-800 Exam Prep Hub main page

Implement auditing – Part 3 (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Implement auditing


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

In Parts 1 and 2, you learned how SQL Server auditing works, how Azure SQL auditing integrates with Azure services, and how auditing supports compliance, monitoring, and forensic investigations. This final section summarizes the topic, compares auditing with related security features, presents real-world scenarios, and concludes with 10 DP-800-style practice exam questions.


Auditing vs. Other SQL Security Features

Understanding the differences between SQL Server security features is critical for the DP-800 exam.

FeaturePurposeProtects Data?Records Activity?
SQL Server AuditRecords security eventsNoYes
Dynamic Data MaskingObscures sensitive dataYesNo
Row-Level SecurityRestricts row accessYesNo
Always EncryptedEncrypts sensitive columnsYesNo
Transparent Data Encryption (TDE)Encrypts database filesYesNo
SQL Server PermissionsControls accessYesNo
Microsoft Defender for SQLDetects suspicious activityIndirectlyPartially

A common exam question is determining which technology satisfies a particular requirement:

  • Need to record who accessed payroll data? → Auditing
  • Need to hide Social Security numbers? → Dynamic Data Masking
  • Need to encrypt credit card numbers? → Always Encrypted
  • Need users to see only their own records? → Row-Level Security
  • Need protection for database files at rest? → Transparent Data Encryption

SQL Server Audit Workflow

A simplified auditing workflow is shown below.

User Action
SQL Server
Audit Specification
(Server or Database)
SQL Server Audit
Audit Target
(File, Azure Storage,
Log Analytics, Event Hub)
Investigation /
Compliance Reporting

Common Audited Events

Organizations commonly audit:

Authentication

  • Successful logins
  • Failed logins
  • Password changes
  • Login creation
  • Login deletion

Administrative Changes

  • CREATE DATABASE
  • DROP DATABASE
  • ALTER DATABASE
  • CREATE LOGIN
  • ALTER LOGIN
  • Server role changes

Security Changes

  • GRANT
  • DENY
  • REVOKE
  • Permission changes
  • Role membership changes

Data Access

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • EXECUTE

Typically, organizations only audit access to sensitive tables rather than every table in the database.


Schema Changes

  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
  • CREATE PROCEDURE
  • ALTER PROCEDURE
  • CREATE VIEW

Real-World Scenario 1

A healthcare provider stores patient records in Azure SQL Database.

Requirements:

  • Record every UPDATE made to patient records.
  • Retain logs for seven years.
  • Alert security personnel when permission changes occur.

Recommended solution:

  • Enable Azure SQL Auditing.
  • Send logs to Azure Storage for long-term retention.
  • Send logs to Log Analytics.
  • Configure Azure Monitor alerts.
  • Forward events to Microsoft Sentinel.

Real-World Scenario 2

A financial institution experiences unauthorized data modifications.

Requirements:

  • Determine who modified account balances.
  • Determine when modifications occurred.
  • Review executed SQL statements.

Solution:

Query audit logs using:

  • sys.fn_get_audit_file() (SQL Server)
  • Log Analytics (Azure SQL)
  • Azure Storage audit files

Review:

  • Login name
  • Timestamp
  • Statement
  • Database
  • Object
  • Session ID

Real-World Scenario 3

A company wants to monitor privileged users only.

Instead of auditing every database action:

Audit:

  • Login events
  • Role changes
  • Permission changes
  • ALTER statements
  • DROP statements

This minimizes performance impact while providing meaningful security visibility.


Compliance Mapping

RequirementSQL Auditing Helps?
Determine who accessed sensitive dataYes
Record failed loginsYes
Detect unauthorized permission changesYes
Track schema modificationsYes
Recover deleted dataNo
Encrypt stored dataNo
Prevent unauthorized accessNo (permissions control access)

Remember:

Auditing provides evidence, not protection.


Performance Best Practices

For production environments:

✔ Audit only important events.

✔ Avoid auditing every SELECT statement unless required.

✔ Archive logs regularly.

✔ Protect audit files with appropriate permissions.

✔ Monitor storage consumption.

✔ Review audit logs routinely.

✔ Test audit configurations before production deployment.

✔ Separate audit storage from transaction log storage whenever practical.


DP-800 Exam Tips

Be comfortable answering questions about:

  • Server Audit vs. Database Audit Specification
  • Azure SQL auditing
  • Audit destinations
  • Log Analytics
  • Azure Storage
  • Event Hubs
  • Microsoft Sentinel
  • Azure Monitor
  • Compliance scenarios
  • Investigating suspicious activity
  • Performance implications of auditing

Quick Review

Remember these key concepts:

TopicKey Point
SQL Server AuditDefines where audit data is stored
Server Audit SpecificationAudits server-level events
Database Audit SpecificationAudits database-level events
Azure StorageLong-term audit storage
Log AnalyticsSearch and analyze audit events
Event HubsStream audit events
Azure MonitorAlerting and dashboards
Microsoft SentinelSIEM and threat investigation
Defender for SQLThreat detection
sys.fn_get_audit_file()Reads SQL Server audit files

Common DP-800 Pitfalls

Avoid these misconceptions:

  • Auditing does not encrypt data.
  • Auditing does not prevent unauthorized access.
  • Auditing is not a replacement for backups.
  • Auditing does not replace Microsoft Defender for SQL.
  • Dynamic Data Masking does not record access.
  • Always Encrypted does not log who viewed data.

Practice Exam Questions

Question 1

A company must determine who modified salary information in the Employees table. Which SQL Server feature should be implemented?

A. Transparent Data Encryption

B. SQL Server Audit

C. Dynamic Data Masking

D. Row-Level Security

Answer: B

Explanation:

SQL Server Audit records database activity, including UPDATE operations, allowing administrators to identify who modified data, when the modification occurred, and which statement was executed. The other options protect or restrict data but do not record user activity.


Question 2

Which SQL Server object specifies where audit records are written?

A. Database Audit Specification

B. Server Audit Specification

C. SQL Server Audit

D. Audit Action Group

Answer: C

Explanation:

The SQL Server Audit object defines the audit destination, such as a file, Windows Security Log, or Windows Application Log. Audit specifications determine which events are captured.


Question 3

An organization wants to search audit logs using Kusto Query Language (KQL). Which Azure service should store the audit data?

A. Azure Storage

B. Event Hubs

C. Log Analytics Workspace

D. Azure Key Vault

Answer: C

Explanation:

Log Analytics stores audit data in a format that supports KQL queries, dashboards, alerts, and Azure Monitor integration. Azure Storage is intended for long-term retention rather than interactive querying.


Question 4

Which audit specification captures database-level activities such as SELECT, UPDATE, and DELETE?

A. Server Audit

B. Database Audit Specification

C. Audit Target

D. Server Audit Specification

Answer: B

Explanation:

Database Audit Specifications capture actions performed within a database, including DML operations and permission changes. Server Audit Specifications capture server-level activities.


Question 5

Which Azure service is primarily intended for streaming audit events to external monitoring systems in near real time?

A. Azure Storage

B. Azure Files

C. Log Analytics

D. Azure Event Hubs

Answer: D

Explanation:

Azure Event Hubs provides scalable event streaming for integration with SIEM platforms, custom monitoring solutions, and security tools. It is optimized for real-time event ingestion.


Question 6

Which function is commonly used to read SQL Server audit files?

A. OPENROWSET()

B. sys.fn_get_audit_file()

C. sp_readaudit

D. sys.fn_audit_log()

Answer: B

Explanation:

sys.fn_get_audit_file() is the built-in table-valued function used to read SQL Server audit files and return audit events in a queryable format.


Question 7

A security administrator needs immediate notification whenever database permissions change. Which solution best meets this requirement?

A. Configure auditing with Log Analytics and Azure Monitor alerts.

B. Disable auditing and use transaction logs.

C. Store audit files only in Azure Storage.

D. Enable Transparent Data Encryption.

Answer: A

Explanation:

Auditing records permission changes, while Azure Monitor can generate alerts based on those audit events stored in Log Analytics. Azure Storage alone does not provide real-time alerting.


Question 8

Which statement correctly describes SQL Server auditing?

A. It encrypts sensitive columns.

B. It prevents unauthorized access to data.

C. It automatically restores deleted records.

D. It records security-related database and server activity.

Answer: D

Explanation:

Auditing records activities for monitoring, compliance, and investigation. It does not encrypt data, restore deleted records, or enforce permissions.


Question 9

Which audit target is generally recommended by Microsoft for most on-premises production SQL Server environments?

A. File

B. Windows Security Log

C. Windows Application Log

D. Azure Event Hubs

Answer: A

Explanation:

File targets provide excellent performance, scalability, and flexibility. They are the recommended destination for most production SQL Server deployments.


Question 10

Which Microsoft security service uses audit information to help detect suspicious database activity and investigate incidents?

A. Azure Backup

B. Microsoft Sentinel

C. SQL Server Agent

D. Azure Resource Manager

Answer: B

Explanation:

Microsoft Sentinel consumes audit logs from services such as Azure SQL Database to correlate events, detect threats, automate investigations, and assist security analysts. It complements auditing by providing advanced security analytics rather than simply recording events.


Final DP-800 Takeaways

For the DP-800 exam, remember these core principles:

  • SQL Server Audit defines where audit records are stored.
  • Server Audit Specifications capture server-level activities such as logins and server role changes.
  • Database Audit Specifications capture database-level activities such as data access and schema changes.
  • Azure Storage is ideal for long-term retention.
  • Log Analytics enables interactive querying, dashboards, and Azure Monitor alerts.
  • Azure Event Hubs supports real-time streaming to external systems.
  • Microsoft Sentinel extends auditing with SIEM capabilities, threat detection, and incident response.
  • Auditing provides accountability, supports compliance, and enables forensic investigations, but it does not replace encryption, access control, or threat protection technologies.

Go to the DP-800 Exam Prep Hub main page

Implement auditing – Part 2 (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Implement auditing


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

In Part 1, you learned about the SQL Server Audit architecture, audit specifications, audit targets, audit action groups, and how to configure and manage audits in SQL Server. In this section, we’ll examine how auditing works in Azure SQL services, how audit data integrates with Azure monitoring solutions, and the performance and operational considerations that are especially relevant for the DP-800 exam.


Auditing in Azure SQL Database

Azure SQL Database includes built-in auditing capabilities that are designed for cloud-native environments. Unlike on-premises SQL Server, Azure SQL Database can automatically integrate with Azure services for centralized monitoring and compliance.

Azure SQL auditing records database events such as:

  • Successful and failed logins
  • Database schema changes
  • Permission modifications
  • Data access (SELECT)
  • Data modifications (INSERT, UPDATE, DELETE)
  • Stored procedure execution
  • Security configuration changes
  • Administrative operations

Auditing can be configured at two levels:

  • Server level
  • Individual database level

Server-level auditing provides a consistent policy across all databases on the logical SQL server, while database-level auditing allows different auditing configurations for specific databases.


Azure SQL Auditing Architecture

Azure SQL Database
SQL Auditing
┌──────┼────────┐
▼ ▼ ▼
Storage Log Analytics Event Hub
Account Workspace

One audit configuration can send events to one or more Azure services.


Audit Destinations in Azure

Unlike SQL Server, Azure SQL Database supports several cloud-based audit destinations.

Azure Storage Account

The most common destination.

Benefits include:

  • Low-cost storage
  • Long-term retention
  • Backup
  • Archive capabilities
  • Easy export
  • Compliance support

Organizations frequently retain audit logs in Storage Accounts for multiple years.


Log Analytics Workspace

Many organizations choose Log Analytics because it supports:

  • Interactive searches
  • Kusto Query Language (KQL)
  • Dashboards
  • Alerting
  • Workbooks
  • Azure Monitor integration

Example investigations include:

  • Failed login trends
  • Privileged user activity
  • Permission changes
  • Suspicious DELETE operations

Azure Event Hubs

Event Hubs allows organizations to stream audit events in near real time.

Typical integrations include:

  • SIEM platforms
  • Security monitoring solutions
  • Custom monitoring applications
  • Third-party security tools

Configuring Azure SQL Auditing

Auditing can be enabled through:

  • Azure Portal
  • Azure CLI
  • PowerShell
  • ARM templates
  • Bicep
  • Terraform
  • Azure REST API

Within the Azure Portal, the configuration typically involves:

  1. Select the SQL Server or database.
  2. Open Auditing under the Security section.
  3. Enable auditing.
  4. Choose one or more destinations.
  5. Configure retention settings.
  6. Save the configuration.

Retention Policies

Azure Storage destinations support configurable retention periods.

Examples include:

  • 90 days
  • 180 days
  • 1 year
  • Multiple years

Retention should match organizational compliance requirements.

Examples:

RegulationTypical Retention
PCI DSSAt least one year
HIPAASeveral years (organization-specific)
SOXOften seven years
Internal security policiesVaries

Azure SQL Managed Instance Auditing

Azure SQL Managed Instance supports auditing capabilities similar to SQL Server while integrating with Azure services.

Supported destinations include:

  • Azure Storage
  • Log Analytics
  • Event Hubs

Managed Instance also supports many SQL Server auditing features, making it easier to migrate on-premises workloads to Azure without redesigning security monitoring.


Microsoft Fabric SQL Auditing Considerations

Microsoft Fabric SQL databases and SQL analytics endpoints are integrated into the broader Microsoft Fabric governance ecosystem.

Rather than relying solely on traditional SQL Server Audit objects, Fabric environments also benefit from:

  • Microsoft Purview governance
  • Activity monitoring
  • Workspace monitoring
  • Capacity monitoring
  • Microsoft Fabric Activity Log
  • Azure Monitor integration
  • Microsoft Defender integration

For the DP-800 exam, understand that auditing in Fabric emphasizes cloud-native monitoring and governance rather than traditional SQL Server Audit files.


Viewing Audit Logs

Azure Portal

Administrators can review:

  • Audit status
  • Destination
  • Retention
  • Recent activity

The portal provides quick access to Log Analytics and Storage Accounts where audit records reside.


Log Analytics

Audit records become searchable using Kusto Query Language (KQL).

Example:

AzureDiagnostics
| where Category == "SQLSecurityAuditEvents"
| where statement_s contains "DELETE"

This query returns DELETE statements captured by SQL auditing.


Storage Account

Audit files stored in Azure Storage can be:

  • Downloaded
  • Archived
  • Imported
  • Processed by external tools
  • Loaded into Power BI
  • Queried with Azure Data Explorer

Integrating Auditing with Azure Monitor

Azure Monitor provides centralized monitoring across Azure resources.

Audit logs can generate:

  • Alerts
  • Dashboards
  • Metrics
  • Workbooks
  • Notifications

Example alert:

Notify the security team whenever more than ten failed login attempts occur within five minutes.


Microsoft Sentinel Integration

Microsoft Sentinel is Microsoft’s cloud-native Security Information and Event Management (SIEM) platform.

Audit logs can be streamed into Sentinel where security analysts can:

  • Detect attacks
  • Investigate incidents
  • Correlate events
  • Create analytics rules
  • Build hunting queries
  • Automate responses

Example scenario:

  1. Repeated failed logins
  2. Successful privileged login
  3. Mass DELETE operations

Sentinel correlates these events into a potential security incident.


Microsoft Defender for SQL

Auditing and Microsoft Defender for SQL complement one another.

AuditingDefender for SQL
Records activityDetects threats
Supports complianceUses behavioral analytics
Captures eventsGenerates security alerts
Used during investigationsIdentifies suspicious behavior

For example:

Auditing records that a user executed a large number of DELETE statements, while Defender for SQL may identify that behavior as anomalous and raise a security alert.


Performance Considerations

Auditing introduces some performance overhead because every audited event must be written to an audit target.

The impact depends on factors such as:

  • Number of audited events
  • Frequency of activity
  • Storage performance
  • Audit destination
  • Network latency (Azure)

Fortunately, SQL Server auditing is highly optimized and generally has minimal impact when configured appropriately.


Reducing Performance Overhead

Microsoft recommends several strategies.

Audit Only Necessary Events

Avoid auditing every possible action.

Instead, focus on:

  • Logins
  • Permission changes
  • Sensitive table access
  • Administrative operations

Avoid Excessive SELECT Auditing

High-volume transactional systems may execute millions of SELECT statements daily.

Auditing every SELECT can:

  • Increase storage consumption
  • Generate enormous audit files
  • Reduce performance

Instead, audit only access to sensitive tables.


Separate Audit Storage

Whenever possible:

  • Store audit files on separate disks.
  • Use dedicated Azure Storage Accounts.
  • Avoid sharing storage with transaction logs.

Archive Older Logs

Large audit repositories become difficult to search.

Implement:

  • Automatic archiving
  • Lifecycle management
  • Long-term storage
  • Periodic cleanup

Monitoring Audit Health

Administrators should routinely verify that auditing is functioning correctly.

Check:

  • Audit status
  • Storage availability
  • Remaining storage capacity
  • Failed audit writes
  • Log Analytics ingestion
  • Event Hub connectivity
  • Audit retention settings

Monitoring helps prevent gaps in audit coverage.


Common Auditing Scenarios

Scenario 1

A hospital must record every update to patient records.

Recommended approach:

  • Database auditing
  • Audit UPDATE operations
  • Store logs in Azure Storage
  • Retain logs according to healthcare regulations

Scenario 2

A bank wants immediate notification when administrators change permissions.

Recommended approach:

  • Audit permission changes
  • Send events to Log Analytics
  • Create Azure Monitor alerts
  • Forward alerts to Microsoft Sentinel

Scenario 3

A company wants to investigate suspicious DELETE statements after a potential insider attack.

Recommended approach:

  • Query audit logs
  • Identify user accounts
  • Review timestamps
  • Correlate activity with authentication logs

Common Mistakes

Candidates often confuse several related security technologies.

FeaturePurpose
AuditingRecords activity
Dynamic Data MaskingHides data
Row-Level SecurityFilters rows
Always EncryptedEncrypts data
Transparent Data EncryptionEncrypts database files
Microsoft Defender for SQLDetects threats

Remember:

  • Auditing records activity.
  • It does not prevent activity.
  • It does not encrypt data.
  • It does not mask data.

DP-800 Exam Tips

Expect scenario-based questions such as:

  • Which audit destination should be selected?
  • Which service enables security investigations?
  • Which Azure service should receive audit logs?
  • How should audits be configured for compliance?
  • Which audit events should be enabled?
  • How can auditing be integrated with Azure Monitor?

Also remember:

  • Azure Storage is commonly used for long-term retention.
  • Log Analytics is best for querying and analysis.
  • Event Hubs is designed for real-time event streaming.
  • Microsoft Sentinel builds on audit logs to provide advanced threat detection and incident response.
  • Microsoft Defender for SQL complements auditing by detecting suspicious behavior rather than simply recording it.

Best Practices Summary

  • Enable auditing for all production databases.
  • Audit only security-relevant events to minimize overhead.
  • Prefer centralized monitoring using Azure Monitor and Log Analytics.
  • Protect audit logs from unauthorized modification or deletion.
  • Configure retention policies that satisfy organizational and regulatory requirements.
  • Integrate auditing with Microsoft Sentinel for security operations.
  • Periodically review audit logs and validate that auditing remains enabled after deployments or configuration changes.
  • Document audit policies and test recovery procedures for audit data.

Go to the DP-800 Exam Prep Hub main page

Implement auditing – Part 1 (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Implement auditing


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

Auditing is a critical security and compliance capability in Microsoft SQL Server, Azure SQL Database, Azure SQL Managed Instance, and Microsoft Fabric SQL databases. An audit records database and server activities so administrators can determine who performed an action, when it occurred, what object was affected, and whether the action succeeded or failed.

Auditing plays an important role in:

  • Security monitoring
  • Regulatory compliance
  • Incident investigations
  • Forensics
  • Insider threat detection
  • Change tracking
  • Governance

For the DP-800 exam, you should understand:

  • SQL Server Audit architecture
  • Server and database audit specifications
  • Audit targets
  • Audited action groups
  • Creating and managing audits
  • Azure SQL auditing
  • Performance considerations
  • Best practices

Why Database Auditing Matters

Unlike backups or transaction logs, auditing focuses on security events rather than data recovery.

Auditing helps answer questions such as:

  • Who deleted a customer record?
  • Who changed employee salaries?
  • Who attempted unauthorized access?
  • Which administrator modified security settings?
  • When was sensitive information viewed?
  • Which login repeatedly failed?

Organizations frequently require auditing for compliance standards including:

  • HIPAA
  • PCI DSS
  • SOX
  • GDPR
  • ISO 27001
  • FedRAMP

SQL Server Audit Architecture

SQL Server auditing is built using three major components.

SQL Server Audit
Audit Target
(File, Windows Security Log,
Windows Application Log)
Audit Specification
(Server or Database)
Audited Actions

The architecture is intentionally modular.


Component 1 — SQL Server Audit

The Audit object defines:

  • Where audit information is written
  • How failures are handled
  • File size
  • Retention behavior
  • Queue delay
  • Whether auditing is enabled

Think of the Audit object as the destination.

Example:

CREATE SERVER AUDIT SecurityAudit
TO FILE
(
FILEPATH = 'D:\AuditLogs\'
);
GO
ALTER SERVER AUDIT SecurityAudit
WITH (STATE = ON);

The audit itself records nothing until specifications are attached.


Component 2 — Audit Specifications

Audit specifications determine what activities should be captured.

Two specification types exist.

Server Audit Specification

Captures server-level events.

Examples include:

  • Login creation
  • Login failures
  • ALTER LOGIN
  • Server role changes
  • Backup operations
  • Database creation
  • Database deletion

Example:

CREATE SERVER AUDIT SPECIFICATION ServerAuditSpec
FOR SERVER AUDIT SecurityAudit
ADD (FAILED_LOGIN_GROUP),
ADD (SERVER_ROLE_MEMBER_CHANGE_GROUP);
ALTER SERVER AUDIT SPECIFICATION ServerAuditSpec
WITH (STATE = ON);

Database Audit Specification

Captures activity inside a database.

Examples:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • EXECUTE
  • Permission changes
  • Schema changes

Example:

USE SalesDB;
CREATE DATABASE AUDIT SPECIFICATION DatabaseAuditSpec
FOR SERVER AUDIT SecurityAudit
ADD (SELECT ON dbo.Customers BY PUBLIC),
ADD (UPDATE ON dbo.Customers BY PUBLIC);
ALTER DATABASE AUDIT SPECIFICATION DatabaseAuditSpec
WITH (STATE =ON);

Relationship Between Audit Objects

SQL Server Audit
├──────────────┐
│ │
▼ ▼
Server Audit Database Audit
Specification Specification
│ │
▼ ▼
Audited Actions Database Actions
Audit Log

One audit may support multiple specifications.


Audit Targets

The audit target specifies where audit events are stored.

SQL Server supports three primary targets.

1. File Target

Most common.

Advantages:

  • High performance
  • Large storage capacity
  • Easy backup
  • Easy archive
  • Supports filtering
  • Recommended by Microsoft

Example

TO FILE
(
FILEPATH='D:\AuditLogs\'
)

2. Windows Security Log

Suitable when:

  • Centralized Windows auditing exists
  • Security teams monitor Security logs
  • Compliance requires OS-level auditing

Advantages

  • Tamper resistant
  • Centrally managed

Requires elevated permissions.


3. Windows Application Log

Less secure than the Security Log.

Typically used when:

  • Security Log permissions are unavailable
  • Simpler deployments
  • Testing environments

Audit Actions

SQL Server audits individual actions or groups of actions.

Examples include:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • EXECUTE
  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
  • LOGIN
  • LOGOUT

Audit Action Groups

Rather than auditing individual commands, SQL Server commonly audits predefined action groups.

Examples include:

Action GroupDescription
FAILED_LOGIN_GROUPFailed logins
SUCCESSFUL_LOGIN_GROUPSuccessful logins
DATABASE_OBJECT_CHANGE_GROUPTable and view changes
DATABASE_PERMISSION_CHANGE_GROUPPermission modifications
SERVER_ROLE_MEMBER_CHANGE_GROUPChanges to server roles
SCHEMA_OBJECT_CHANGE_GROUPCREATE/ALTER/DROP objects
DATABASE_ROLE_MEMBER_CHANGE_GROUPChanges to database roles
BACKUP_RESTORE_GROUPBackup and restore events
SERVER_OBJECT_CHANGE_GROUPServer object modifications

These predefined groups simplify auditing and reduce administrative effort.


Creating a Basic Audit

Step 1

Create the audit.

CREATE SERVER AUDIT MyAudit
TO FILE
(
FILEPATH='D:\AuditLogs\'
);

Step 2

Enable the audit.

ALTER SERVER AUDIT MyAudit
WITH (STATE=ON);

Step 3

Create a database audit specification.

USE SalesDB;
CREATE DATABASE AUDIT SPECIFICATION SalesAudit
FOR SERVER AUDIT MyAudit
ADD
(
SELECT ON dbo.Customers BY PUBLIC
);

Step 4

Enable the specification.

ALTER DATABASE AUDIT SPECIFICATION SalesAudit
WITH (STATE=ON);

Now every SELECT against Customers is captured.


Viewing Audit Logs

Audit files can be queried using the built-in table-valued function:

SELECT *
FROM sys.fn_get_audit_file
(
'D:\AuditLogs\*',
DEFAULT,
DEFAULT
);

Returned information includes:

  • Event time
  • Login name
  • Database name
  • Server name
  • Object name
  • Statement executed
  • Action ID
  • Session ID
  • Success or failure

This function is commonly used for reporting and investigations.


Managing Audit State

Audits can be enabled or disabled without deleting them.

Disable:

ALTER SERVER AUDIT SecurityAudit
WITH (STATE = OFF);

Enable:

ALTER SERVER AUDIT SecurityAudit
WITH (STATE = ON);

Similarly, individual audit specifications can be enabled or disabled independently of the audit object.


Catalog Views for Auditing

Several system catalog views help administrators monitor audit configuration.

ViewPurpose
sys.server_auditsLists configured server audits
sys.server_audit_specificationsLists server audit specifications
sys.database_audit_specificationsLists database audit specifications
sys.server_audit_specification_detailsDisplays server audit actions
sys.database_audit_specification_detailsDisplays database audit actions
sys.dm_server_audit_statusShows audit runtime status

Example:

SELECT *
FROM sys.server_audits;

Audit Failure Behavior

SQL Server allows administrators to specify what happens if an audit target becomes unavailable.

Options include:

Continue

Database operations continue even if auditing fails.

Suitable for:

  • Development environments
  • Non-critical systems

Fail Operation

Only the audited operation fails.

Example:

  • A user attempts to update a table.
  • The audit cannot write to disk.
  • The UPDATE is rejected.

This option helps ensure sensitive operations are never performed without being audited.


Shut Down Server

The SQL Server instance shuts down if auditing fails.

This provides the highest level of security but can impact availability. It is generally reserved for environments with strict regulatory requirements.


Best Practices

Microsoft recommends the following auditing practices:

  • Audit only important security events to reduce overhead.
  • Prefer file targets for performance and scalability.
  • Protect audit files with appropriate NTFS permissions.
  • Archive audit logs regularly.
  • Monitor available disk space to prevent audit interruptions.
  • Test audit configurations before deploying to production.
  • Use separate storage volumes for audit files when possible.
  • Review audit logs regularly rather than collecting them without analysis.
  • Combine auditing with least-privilege security and Microsoft Defender for SQL for comprehensive protection.
  • Document audit policies to satisfy compliance requirements and facilitate incident response.

DP-800 Exam Tips

  • Understand the distinction between a SQL Server Audit (defines the destination) and an Audit Specification (defines what is captured).
  • Know when to use Server Audit Specifications versus Database Audit Specifications.
  • Be familiar with common audit action groups, especially login, permission, object change, and backup-related groups.
  • Remember that sys.fn_get_audit_file is the primary method for reading audit files.
  • Recognize that file targets are generally Microsoft’s recommended choice for production deployments because they offer the best balance of performance, scalability, and manageability.
  • Be able to identify scenarios where auditing supports regulatory compliance, forensic investigations, and security monitoring.

Go to the DP-800 Exam Prep Hub main page

Implement secure database access, including passwordless (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Implement secure database access, including passwordless


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

One of the primary responsibilities of a SQL AI Developer is ensuring that applications and users access databases securely. As organizations move toward cloud-native architectures and zero-trust security models, traditional username-and-password authentication is increasingly being replaced by more secure alternatives such as passwordless authentication, Microsoft Entra ID (formerly Azure Active Directory), managed identities, and service principals.

The DP-800 exam expects candidates to understand how to design secure authentication and authorization strategies for SQL Server, Azure SQL Database, Azure SQL Managed Instance, and Microsoft Fabric SQL solutions. Candidates should also understand when to use SQL authentication versus Microsoft Entra authentication, how passwordless authentication works, and how applications securely connect to databases without embedding secrets.


Authentication vs. Authorization

A common exam objective is distinguishing authentication from authorization.

Authentication answers the question:

Who are you?

Authentication verifies the identity of a user or application.

Examples include:

  • Microsoft Entra ID login
  • SQL login
  • Windows Authentication
  • Managed Identity
  • Service Principal

Authorization answers the question:

What are you allowed to do?

Authorization determines permissions after authentication succeeds.

Examples include:

  • SELECT permission
  • EXECUTE permission
  • Database roles
  • Row-Level Security (RLS)
  • Object-level permissions

Authentication always occurs before authorization.


Types of Database Authentication

SQL Server supports multiple authentication methods.

Authentication MethodTypical Usage
Windows AuthenticationOn-premises Active Directory environments
SQL AuthenticationUsername and password stored in SQL Server
Microsoft Entra AuthenticationAzure SQL Database and Fabric
Managed IdentityAzure-hosted services
Service PrincipalAutomated applications and DevOps
Passwordless AuthenticationMicrosoft Entra authentication without passwords

SQL Authentication

SQL Authentication uses a SQL login and password stored by SQL Server.

Example:

CREATE LOGIN SalesUser
WITH PASSWORD = 'StrongPassword123!';

Advantages:

  • Easy to configure
  • Supported by virtually every SQL client
  • Independent of Active Directory

Disadvantages:

  • Password management required
  • Password rotation required
  • Secrets must often be stored in applications
  • Higher risk of credential theft

Microsoft recommends minimizing the use of SQL authentication whenever possible, particularly in Azure environments.


Windows Authentication

Windows Authentication uses Active Directory credentials.

Advantages:

  • Integrated security
  • Single sign-on (SSO)
  • Centralized identity management
  • Kerberos authentication
  • Password policies enforced automatically

Common connection string:

Integrated Security=True;

This is the preferred authentication method for on-premises SQL Server environments.


Microsoft Entra Authentication

Microsoft Entra ID is Microsoft’s cloud identity provider and is the preferred authentication mechanism for Azure SQL services.

Benefits include:

  • Single Sign-On (SSO)
  • Multi-Factor Authentication (MFA)
  • Conditional Access
  • Centralized identity management
  • Passwordless authentication support
  • Identity governance
  • Integration with Microsoft Fabric

Users authenticate through Microsoft Entra instead of SQL logins.

Example workflow:

User
Microsoft Entra ID
Azure SQL Database

Passwordless Authentication

Passwordless authentication eliminates traditional passwords while maintaining strong identity verification.

Instead of passwords, authentication may use:

  • Windows Hello for Business
  • Microsoft Authenticator
  • FIDO2 Security Keys
  • Passkeys
  • Biometric authentication
  • Managed Identities
  • Microsoft Entra tokens

Benefits include:

  • Eliminates password theft
  • Prevents password reuse
  • Reduces phishing attacks
  • Removes password rotation requirements
  • Improves user experience

Microsoft strongly recommends passwordless authentication whenever possible.


How Passwordless Authentication Works

Instead of sending a password:

Application
Obtains Microsoft Entra access token
Azure SQL Database validates token
Connection established

The database trusts Microsoft Entra rather than validating a stored password.


Managed Identity

Managed Identity is one of the most important DP-800 topics.

A Managed Identity is an identity automatically managed by Azure for Azure resources.

Examples:

  • Azure App Service
  • Azure Functions
  • Azure Virtual Machines
  • Azure Container Apps
  • Azure Kubernetes Service
  • Azure Logic Apps

Instead of storing credentials:

Application
Managed Identity
Microsoft Entra ID
Azure SQL Database

No passwords are stored.


Advantages of Managed Identity

Benefits include:

  • No stored passwords
  • Automatic credential rotation
  • Short-lived access tokens
  • Integrated with Microsoft Entra
  • Easier compliance
  • Reduced security risk

This is Microsoft’s recommended approach for Azure-hosted applications.


Service Principals

A Service Principal represents an application rather than a person.

Common uses include:

  • CI/CD pipelines
  • Azure DevOps
  • GitHub Actions
  • Background services
  • Automation scripts

Service principals authenticate through Microsoft Entra and can access Azure SQL databases securely.


Access Tokens

Modern Azure SQL authentication uses OAuth access tokens.

Instead of:

Username
Password

Applications obtain:

Microsoft Entra Access Token

The token:

  • Has a limited lifetime
  • Cannot be reused indefinitely
  • Reduces credential theft
  • Supports Conditional Access policies

Configuring Microsoft Entra Authentication

Typical steps include:

  1. Configure a Microsoft Entra administrator for the SQL server.
  2. Create Microsoft Entra users or groups.
  3. Create contained database users.
  4. Assign database roles.
  5. Grant required permissions.

Example:

CREATE USER [Alice@contoso.com]
FROM EXTERNAL PROVIDER;

Grant role:

ALTER ROLE db_datareader
ADD MEMBER [Alice@contoso.com];

No SQL password is required.


Contained Database Users

Contained database users simplify authentication.

Advantages:

  • No SQL login required
  • Database portability
  • Simplified Azure SQL deployments
  • Works well with Microsoft Entra identities

Example:

CREATE USER [Developers]
FROM EXTERNAL PROVIDER;

Secure Connection Strings

Avoid storing:

Server=myserver;
User ID=admin;
Password=Password123;

Instead, use Microsoft Entra authentication.

Example (.NET):

Authentication=Active Directory Default;

The application automatically acquires an access token using the available identity.


Connection Security

Authentication should be combined with encrypted network connections.

Best practices include:

  • Require TLS encryption
  • Validate server certificates
  • Encrypt all client-server communication
  • Disable legacy protocols

Azure SQL encrypts client connections by default.


Principle of Least Privilege

Applications should receive only the permissions they require.

Example:

Application needs:

  • Execute stored procedures

Application does not need:

  • ALTER DATABASE
  • CONTROL
  • db_owner

Using least privilege minimizes security risks.


Passwordless Authentication with Azure Services

Many Azure services automatically support Managed Identity.

Example:

Azure Function
Managed Identity
Microsoft Entra
Azure SQL Database

No secrets are stored in code or configuration files.


Microsoft Fabric Integration

Microsoft Fabric integrates closely with Microsoft Entra ID.

Fabric workloads support:

  • Microsoft Entra authentication
  • Single Sign-On
  • Role-based access
  • Passwordless identity
  • Unified identity management

DP-800 candidates should understand that Fabric relies heavily on Microsoft Entra identities rather than SQL logins.


Security Best Practices

Microsoft recommends:

  • Prefer Microsoft Entra authentication over SQL authentication.
  • Use passwordless authentication whenever possible.
  • Enable Multi-Factor Authentication (MFA).
  • Use Managed Identity for Azure-hosted applications.
  • Use Service Principals for automation.
  • Avoid embedding credentials in source code.
  • Store secrets in Azure Key Vault if passwords or keys are unavoidable.
  • Rotate credentials regularly when passwords must be used.
  • Use TLS encryption for all database connections.
  • Follow the principle of least privilege.
  • Audit authentication events regularly.
  • Use Conditional Access policies to protect administrative accounts.

Common DP-800 Exam Scenarios

You may be asked to determine:

  • Which authentication method is most secure.
  • When to use Managed Identity.
  • When to use Microsoft Entra authentication.
  • How passwordless authentication works.
  • When SQL Authentication is appropriate.
  • How applications connect without passwords.
  • How service principals authenticate.
  • How contained database users simplify Azure SQL deployments.
  • How to eliminate secrets from connection strings.
  • How to secure Azure-hosted AI applications accessing SQL databases.

DP-800 Exam Tips

Remember these key points:

  • Microsoft Entra ID is the preferred authentication mechanism for Azure SQL.
  • Passwordless authentication reduces phishing and credential theft.
  • Managed Identities eliminate stored passwords.
  • Service Principals authenticate applications and automation.
  • SQL Authentication still exists but is less secure.
  • Authentication verifies identity; authorization controls permissions.
  • Use least privilege for both users and applications.
  • Azure SQL supports OAuth access tokens instead of passwords.
  • Fabric uses Microsoft Entra authentication extensively.

Practice Exam Questions

Question 1

Which authentication method is Microsoft’s recommended approach for Azure-hosted applications connecting to Azure SQL Database?

A. Managed Identity

B. SQL Authentication

C. Windows Authentication

D. Shared SQL Administrator account

Correct Answer: A

Explanation:
Managed Identity eliminates the need to store credentials, automatically manages identity, and integrates with Microsoft Entra ID, making it Microsoft’s preferred authentication method for Azure-hosted applications.


Question 2

What is the primary purpose of passwordless authentication?

A. Improve query performance

B. Eliminate traditional passwords while securely verifying identity

C. Replace authorization

D. Encrypt database backups

Correct Answer: B

Explanation:
Passwordless authentication replaces passwords with stronger authentication mechanisms such as biometrics, security keys, Microsoft Authenticator, or access tokens, reducing the risk of credential theft.


Question 3

Which statement correctly distinguishes authentication from authorization?

A. Authentication determines database roles; authorization creates logins.

B. Authentication encrypts data; authorization decrypts it.

C. Authentication verifies identity, while authorization determines what actions are permitted.

D. Authentication assigns object permissions, while authorization validates passwords.

Correct Answer: C

Explanation:
Authentication confirms who a user or application is, whereas authorization determines what resources and operations that authenticated identity may access.


Question 4

A development team wants to eliminate database passwords from application configuration files. Which solution best meets this requirement?

A. Store SQL passwords in source code.

B. Use SQL Authentication with stronger passwords.

C. Share one administrator account among all applications.

D. Use Microsoft Entra authentication with Managed Identity.

Correct Answer: D

Explanation:
Managed Identity allows applications to authenticate without storing passwords or secrets, significantly improving security and simplifying credential management.


Question 5

Which authentication method is commonly used for automated CI/CD pipelines and background services?

A. Windows Authentication

B. Service Principal

C. SQL Authentication

D. Database Owner account

Correct Answer: B

Explanation:
Service Principals represent applications rather than users and are commonly used by automation tools such as Azure DevOps and GitHub Actions.


Question 6

Which feature is automatically provided by Managed Identity?

A. Automatic query tuning

B. Automatic index creation

C. Automatic credential rotation

D. Automatic data encryption

Correct Answer: C

Explanation:
Managed Identity automatically handles credential creation and rotation, eliminating the need for administrators or developers to manage passwords.


Question 7

Which SQL statement creates a Microsoft Entra user in an Azure SQL Database?

A.

CREATE LOGIN Alice WITH PASSWORD='Password123';

B.

CREATE USER Alice WITHOUT LOGIN;

C.

CREATE USER [Alice@contoso.com] FROM EXTERNAL PROVIDER;

D.

CREATE ROLE Alice;

Correct Answer: C

Explanation:
The FROM EXTERNAL PROVIDER clause creates a contained database user that authenticates through Microsoft Entra ID rather than a SQL login.


Question 8

Which security principle recommends granting only the permissions required for a user or application to perform its work?

A. Ownership chaining

B. Principle of least privilege

C. Password complexity

D. Data masking

Correct Answer: B

Explanation:
Least privilege minimizes security risks by limiting permissions to only those necessary for the required tasks.


Question 9

Which authentication mechanism does Azure SQL Database use with Microsoft Entra authentication?

A. Static passwords

B. Kerberos tickets only

C. SQL login hashes

D. OAuth access tokens

Correct Answer: D

Explanation:
Microsoft Entra authentication relies on OAuth access tokens, which are short-lived and securely validated by Azure SQL Database.


Question 10

Why is Microsoft Entra authentication generally preferred over SQL Authentication for Azure SQL Database?

A. It requires longer passwords.

B. It supports centralized identity management, MFA, Conditional Access, and passwordless authentication.

C. It eliminates database roles.

D. It removes the need for database permissions.

Correct Answer: B

Explanation:
Microsoft Entra authentication provides enterprise-grade identity management features, including Single Sign-On, Multi-Factor Authentication, Conditional Access, centralized administration, and support for passwordless authentication, making it more secure than traditional SQL Authentication.


Go to the DP-800 Exam Prep Hub main page

Design and implement object-level permissions (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Design and implement object-level permissions


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

Securing data is one of the most important responsibilities of a SQL developer. While server-level and database-level permissions determine who can connect to SQL Server and access databases, object-level permissions determine what users can do with individual database objects such as tables, views, stored procedures, functions, sequences, and schemas.

The DP-800 certification expects candidates to understand how to implement the principle of least privilege, ensuring that users receive only the permissions required to perform their jobs.

Object-level permissions are a fundamental component of SQL Server security and are widely used in:

  • Microsoft SQL Server
  • Azure SQL Database
  • Azure SQL Managed Instance
  • Microsoft Fabric SQL Database
  • SQL Database in Fabric Warehouses (where supported)

Understanding how permissions are inherited, granted, denied, revoked, and combined with roles is essential for designing secure database solutions.


What Are Object-Level Permissions?

Object-level permissions control access to individual database objects rather than the entire database.

For example, one user might:

  • Read data from a table
  • Execute a stored procedure
  • Update rows in another table
  • View metadata
  • Create indexes

while another user has completely different permissions.

Unlike database-level permissions, object permissions provide very granular security.

Example:

Sales.Customers
Sales.Orders
Sales.Products
HR.Employees

A salesperson may have access to Sales tables but no access to HR tables.


Common Database Objects That Can Be Secured

Permissions can be assigned to numerous SQL Server objects, including:

  • Tables
  • Views
  • Stored procedures
  • Functions
  • Schemas
  • Sequences
  • Synonyms
  • External tables
  • User-defined types
  • XML schema collections
  • Service Broker objects

DP-800 focuses primarily on:

  • Tables
  • Views
  • Stored procedures
  • Functions
  • Schemas

Permission Hierarchy

Permissions exist at several levels.

Server
Database
Schema
Object

Example:

Database
Sales
Schema
Sales
Table
Orders

Permissions granted on the schema may automatically apply to objects within that schema.


Common Object Permissions

The most commonly used permissions include:

PermissionPurpose
SELECTRead rows
INSERTAdd rows
UPDATEModify rows
DELETERemove rows
EXECUTERun stored procedures/functions
REFERENCESCreate foreign keys
ALTERModify an object
CONTROLFull control over an object
TAKE OWNERSHIPChange ownership
VIEW DEFINITIONView object definition

GRANT

GRANT gives permissions.

Example

GRANT SELECT
ON Sales.Orders
TO SalesUser;

The user can now query the table.


Example

GRANT INSERT, UPDATE
ON Sales.Orders
TO SalesUser;

Multiple permissions can be granted simultaneously.


Grant execute permission

GRANT EXECUTE
ON dbo.usp_ProcessOrders
TO SalesUser;

The user may execute the procedure without having direct table permissions.


DENY

DENY explicitly prevents access.

Example

DENY DELETE
ON Sales.Orders
TO SalesUser;

Even if another role grants DELETE, DENY overrides it.

This is one of the most important security concepts on the DP-800 exam.


REVOKE

REVOKE removes previously granted or denied permissions.

Example

REVOKE SELECT
ON Sales.Orders
FROM SalesUser;

REVOKE does not deny access.

It simply removes the explicit permission.


GRANT vs DENY vs REVOKE

CommandEffect
GRANTAllows access
DENYExplicitly blocks access
REVOKERemoves a GRANT or DENY

Permission Precedence

SQL Server evaluates permissions using precedence rules.

Highest priority:

DENY

Lower priority:

GRANT

Example

User belongs to:

SalesRole

SalesRole:

GRANT SELECT

Another role:

DENY SELECT

Result:

User cannot SELECT.

DENY wins.


Granting Permissions to Roles

Best practice is to grant permissions to roles rather than directly to users.

Example

CREATE ROLE SalesReaders;

Grant permission

GRANT SELECT
ON Sales.Orders
TO SalesReaders;

Add user

ALTER ROLE SalesReaders
ADD MEMBER Alice;

This greatly simplifies administration.


Schema-Level Permissions

Instead of granting access to each table individually, permissions may be granted on an entire schema.

Example

GRANT SELECT
ON SCHEMA::Sales
TO SalesReaders;

The role receives SELECT permission on all objects within the Sales schema.


Stored Procedure Permissions

Applications often use stored procedures instead of direct table access.

Example

GRANT EXECUTE
ON dbo.usp_GetCustomerOrders
TO AppUser;

Users execute the procedure without needing direct permissions on the underlying tables (ownership chaining permitting).

Benefits include:

  • Better security
  • Reduced attack surface
  • Easier auditing
  • Centralized business logic

View Permissions

Views frequently expose only selected columns or rows.

Example

GRANT SELECT
ON Sales.vCustomerSummary
TO SalesReaders;

Applications query the view rather than the underlying table.

Advantages include:

  • Hide sensitive columns
  • Simplify queries
  • Provide logical security boundaries

Function Permissions

Scalar and table-valued functions also require EXECUTE permission.

Example

GRANT EXECUTE
ON dbo.fn_CalculateDiscount
TO SalesUser;

Ownership Chaining

Ownership chaining occurs when objects owned by the same owner access one another.

Example

User
Stored Procedure
Table

If both objects share the same owner:

  • SQL Server does not perform additional permission checks on the table.

Benefits:

  • Simplifies application security
  • Eliminates unnecessary table permissions
  • Improves manageability

DP-800 frequently tests this concept.


Least Privilege Principle

One of Microsoft’s most important security recommendations.

Users should receive:

  • Only the permissions required
  • Nothing more

Poor example

db_owner

Better example

SELECT
EXECUTE

Grant only what is necessary.


Avoid Granting db_owner

Many organizations incorrectly solve permission issues by granting db_owner.

Problems:

  • Full database control
  • Can drop objects
  • Can change security
  • Can alter schemas
  • Increased security risk

Instead:

  • Create custom roles
  • Grant only required permissions

Object Permissions and AI Applications

Modern AI-enabled SQL solutions frequently access databases through:

  • APIs
  • Stored procedures
  • Semantic search
  • Retrieval-Augmented Generation (RAG)
  • Microsoft Fabric
  • Copilot applications

Best practice:

AI applications should never connect using highly privileged accounts.

Instead:

  • Create service accounts.
  • Grant only EXECUTE on required procedures or SELECT on approved views.
  • Avoid direct access to sensitive tables.
  • Combine object permissions with Row-Level Security (RLS), Dynamic Data Masking (DDM), and Always Encrypted where appropriate.

This approach reduces the risk of exposing sensitive information through AI-assisted applications.


Best Practices

Microsoft recommends:

  • Grant permissions through roles.
  • Follow least privilege.
  • Prefer views over direct table access.
  • Use stored procedures for data modifications.
  • Avoid granting db_owner.
  • Regularly audit permissions.
  • Remove unused permissions.
  • Use schema-based permissions when appropriate.
  • Minimize explicit DENY statements unless required.
  • Combine object permissions with other SQL Server security features.

DP-800 Exam Tips

Candidates should know how to:

  • Grant object permissions
  • Revoke permissions
  • Deny permissions
  • Understand permission inheritance
  • Secure stored procedures
  • Secure views
  • Grant schema permissions
  • Use database roles
  • Explain ownership chaining
  • Apply least privilege
  • Understand permission precedence
  • Determine the effect of GRANT, DENY, and REVOKE
  • Design secure access models for AI-enabled database applications

Practice Exam Questions

Question 1

A database developer wants users to read data from the Sales.Orders table but prevent any modifications. Which permission should be granted?

A. EXECUTE

B. SELECT

C. ALTER

D. CONTROL

Correct Answer: B

Explanation:
The SELECT permission allows users to read rows from a table without permitting INSERT, UPDATE, or DELETE operations.


Question 2

A user belongs to two database roles. One role grants SELECT permission on a table, while the other role explicitly denies SELECT permission. What is the result?

A. SQL Server ignores the DENY.

B. SQL Server randomly selects one permission.

C. The user can still read the table.

D. The user cannot read the table.

Correct Answer: D

Explanation:
DENY takes precedence over GRANT. An explicit DENY overrides any granted permissions from other roles.


Question 3

Which statement is the recommended method for assigning permissions to multiple users?

A. Grant permissions directly to every user.

B. Add every user to db_owner.

C. Create database roles and grant permissions to the roles.

D. Use only server-level permissions.

Correct Answer: C

Explanation:
Assigning permissions to roles simplifies administration, improves consistency, and aligns with Microsoft security best practices.


Question 4

Which command removes a previously granted permission without explicitly denying access?

A.

REVOKE

B.

DENY

C.

REMOVE

D.

DROP

Correct Answer: A

Explanation:
REVOKE removes an existing GRANT or DENY. It does not prohibit future access unless another permission remains in effect.


Question 5

An application should execute a stored procedure but should not have direct access to the underlying tables. Which permission should be granted?

A. SELECT on every table

B. CONTROL on the database

C. EXECUTE on the stored procedure

D. ALTER on the schema

Correct Answer: C

Explanation:
Granting EXECUTE on the stored procedure allows users to perform approved operations without direct table access, leveraging ownership chaining when applicable.


Question 6

Which permission allows a user to modify the definition of an existing table?

A. ALTER

B. SELECT

C. EXECUTE

D. REFERENCES

Correct Answer: A

Explanation:
The ALTER permission enables changes to an object’s definition, such as adding or removing columns from a table.


Question 7

A database administrator grants SELECT permission on an entire schema. What is the primary benefit?

A. It encrypts every table in the schema.

B. It automatically creates new users.

C. It applies permissions to objects within the schema, simplifying administration.

D. It replaces Row-Level Security.

Correct Answer: C

Explanation:
Schema-level permissions reduce administrative effort by applying permissions to objects contained within the schema, rather than requiring individual grants on each object.


Question 8

Which principle recommends granting users only the permissions they require to perform their jobs?

A. Defense in depth

B. Separation of duties

C. Ownership chaining

D. Least privilege

Correct Answer: D

Explanation:
The principle of least privilege minimizes security risks by limiting permissions to only those necessary for a user’s responsibilities.


Question 9

Why is granting the db_owner role to application accounts generally discouraged?

A. It prevents applications from executing stored procedures.

B. It provides unnecessary administrative privileges and increases security risk.

C. It disables ownership chaining.

D. It prevents schema-level permissions from working.

Correct Answer: B

Explanation:
The db_owner role grants full control over the database, which violates the principle of least privilege and can expose the database to accidental or malicious changes.


Question 10

Which database object permission is required to run a user-defined function?

A. SELECT

B. UPDATE

C. EXECUTE

D. ALTER

Correct Answer: C

Explanation:
User-defined functions, like stored procedures, require the EXECUTE permission to be invoked by users or applications.


Go to the DP-800 Exam Prep Hub main page

Design and implement Row-Level Security (RLS) (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Design and implement Row-Level Security (RLS)


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

What is Row-Level Security (RLS)?

Row-Level Security (RLS) is a SQL Server and Azure SQL Database feature that restricts which rows a user can access based on a security policy. Rather than controlling access to an entire table, RLS filters data so that users see only the rows they are authorized to view.

For example, a Sales table might contain data for all sales regions:

SalesPersonRegionSales
AliceEast125000
BobWest98000
CarolNorth143000
DavidSouth110000

With RLS enabled:

  • Alice sees only East region rows.
  • Bob sees only West region rows.
  • Regional managers see only their assigned regions.
  • Executives may see all rows.

The application continues to query the entire table, but SQL Server automatically filters the results.


Why Use Row-Level Security?

Many organizations have users who should share the same tables while viewing different subsets of the data.

Common scenarios include:

  • Multi-tenant Software-as-a-Service (SaaS) applications
  • Regional sales reporting
  • Department-specific HR records
  • Healthcare systems where providers access only their patients
  • Educational systems where instructors see only their own students
  • Financial institutions with branch-specific records

Without RLS, developers often implement filtering within application code. RLS centralizes these security rules inside the database, reducing development effort and improving security.


How Row-Level Security Works

RLS works by attaching a security policy to a table.

When a query executes:

  1. SQL Server identifies the current user.
  2. A predicate function evaluates each row.
  3. Only rows that satisfy the predicate are returned.

This occurs automatically without modifying application queries.


Row-Level Security Architecture

Application
SELECT * FROM Orders
Security Policy
Predicate Function
Only Authorized Rows Returned

The application does not need to include a WHERE clause because SQL Server applies the filtering automatically.


Components of Row-Level Security

RLS consists of three primary components:

1. Predicate Function

A predicate function determines whether a row should be visible.

Typically, this is an inline table-valued function.

Example:

CREATE FUNCTION Security.fn_FilterSales
(
@SalesRegion NVARCHAR(50)
)
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT 1 AS fn_result
WHERE @SalesRegion = USER_NAME();

This function allows users to see rows only when the SalesRegion value matches their database user name.


2. Security Policy

The security policy associates the predicate function with a table.

Example:

CREATE SECURITY POLICY SalesFilter
ADD FILTER PREDICATE
Security.fn_FilterSales(SalesRegion)
ON dbo.Sales
WITH (STATE = ON);

Once enabled, every query against the Sales table automatically uses the filter.


3. Protected Table

The protected table contains the actual business data.

Applications continue to issue normal SELECT, UPDATE, DELETE, and MERGE statements while SQL Server enforces the policy.


Types of Security Predicates

SQL Server supports two predicate types.

Filter Predicate

A filter predicate limits which rows users can read.

Example:

SELECT *
FROM Sales;

The query returns only rows authorized by the security policy.

This is the most commonly used predicate.


Block Predicate

A block predicate prevents unauthorized modifications.

It can prevent:

  • INSERT
  • UPDATE
  • DELETE

Example:

A user may be allowed to read only West region rows and may also be prevented from inserting East region records.


Block Predicate Types

Block predicates can be applied:

  • BEFORE INSERT
  • AFTER INSERT
  • BEFORE UPDATE
  • AFTER UPDATE
  • BEFORE DELETE

This provides fine-grained control over data modifications.


Example: Multi-Tenant Application

Imagine a SaaS application storing customer records.

CustomerIDTenantIDCustomerName
101TenantAABC Company
102TenantBXYZ Industries
103TenantAContoso Ltd

Instead of creating separate databases for every customer, one database stores all tenants.

The predicate function filters rows by TenantID so that:

  • TenantA users see only TenantA records.
  • TenantB users see only TenantB records.

Applications require no additional filtering logic.


Example: Sales Regions

Sales table:

EmployeeRegion
AliceEast
BobWest
CarolEast
DavidSouth

Logged-in user:

EastManager

Predicate:

WHERE Region = USER_NAME()

Result:

EmployeeRegion
AliceEast
CarolEast

Other regions are invisible.


Creating an RLS Policy

Step 1: Create Schema

CREATE SCHEMA Security;

Step 2: Create Predicate Function

CREATE FUNCTION Security.fn_FilterRegion
(
@Region NVARCHAR(50)
)
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT 1
WHERE @Region = USER_NAME();

Step 3: Create Security Policy

CREATE SECURITY POLICY RegionFilter
ADD FILTER PREDICATE
Security.fn_FilterRegion(Region)
ON dbo.Sales
WITH (STATE = ON);

The policy immediately begins protecting the table.


Disabling a Security Policy

ALTER SECURITY POLICY RegionFilter
WITH (STATE = OFF);

The policy remains defined but no longer filters data.


Re-enabling the Policy

ALTER SECURITY POLICY RegionFilter
WITH (STATE = ON);

Dropping a Security Policy

DROP SECURITY POLICY RegionFilter;

Security Context Functions

RLS frequently uses identity functions.

Common examples include:

FunctionPurpose
USER_NAME()Current database user
SUSER_SNAME()Login name
SESSION_CONTEXT()Session-specific values
ORIGINAL_LOGIN()Original login before impersonation

These functions allow security decisions based on the current user or application context.


SESSION_CONTEXT()

Many enterprise applications use SESSION_CONTEXT() rather than database usernames.

Example:

EXEC sp_set_session_context
@key='TenantID',
@value='TenantA';

Predicate:

WHERE
@TenantID =
SESSION_CONTEXT(N'TenantID');

This approach works well in web applications where many users connect using a shared database login.


Benefits of Row-Level Security

Centralized Security

Rules exist inside the database instead of multiple applications.


Transparent to Applications

Applications issue normal SQL statements.

No code changes are typically required.


Consistent Enforcement

Every query is filtered automatically.

Developers cannot accidentally omit security filters.


Simplifies Development

No need to duplicate WHERE clauses throughout application code.


Improved Maintainability

Security policies can be updated without changing application logic.


Limitations

Not a Replacement for Authentication

Users must still authenticate.

RLS determines only which rows are visible.


Does Not Encrypt Data

Use:

  • Always Encrypted
  • Transparent Data Encryption (TDE)

when encryption is required.


Does Not Mask Data

Use:

  • Dynamic Data Masking

when users should see masked values instead of hidden rows.


Predicate Performance

Complex predicate functions can reduce query performance.

Predicate functions should remain efficient.


RLS vs Dynamic Data Masking

Row-Level SecurityDynamic Data Masking
Hides rowsMasks column values
User cannot see unauthorized recordsUser sees rows but masked data
Controls access to recordsControls visibility of sensitive columns
Based on predicatesBased on masking functions
Often used with DDMOften combined with RLS

RLS vs Always Encrypted

Row-Level SecurityAlways Encrypted
Controls visible rowsEncrypts stored values
Server evaluates predicatesClient decrypts data
Data remains readable by authorized usersDatabase cannot read encrypted values without client-side decryption
Access controlConfidentiality protection

Best Practices

Keep Predicate Functions Simple

Simple predicates improve query performance.


Use SCHEMABINDING

Predicate functions should use:

WITH SCHEMABINDING

This prevents changes that could invalidate the security policy.


Use SESSION_CONTEXT() for Web Applications

This scales better than relying solely on database usernames.


Test with Non-Administrative Accounts

Database administrators often bypass normal security scenarios.

Always validate RLS using standard user accounts.


Combine with Other Security Features

For comprehensive protection, combine RLS with:

  • Dynamic Data Masking
  • Always Encrypted
  • Transparent Data Encryption
  • Microsoft Entra authentication
  • Least-privilege permissions
  • SQL auditing

DP-800 Exam Tips

Candidates should be able to:

  • Explain the purpose of Row-Level Security.
  • Differentiate filter predicates from block predicates.
  • Understand the role of predicate functions and security policies.
  • Create RLS using inline table-valued functions.
  • Enable, disable, and drop security policies.
  • Use USER_NAME(), SUSER_SNAME(), and SESSION_CONTEXT() in predicate functions.
  • Differentiate RLS from Dynamic Data Masking and Always Encrypted.
  • Identify common scenarios such as multi-tenant SaaS applications.
  • Recognize that RLS is transparent to application code.

Practice Exam Questions

Question 1

A company stores sales records for all regions in a single table. Regional managers should view only the rows for their assigned region.

Which SQL Server feature should you implement?

A. Transparent Data Encryption

B. Row-Level Security

C. Dynamic Data Masking

D. Always Encrypted

Answer: B

Explanation: Row-Level Security filters rows based on a security policy so users automatically see only the records they are authorized to access.


Question 2

Which object determines whether a row is visible to a user in Row-Level Security?

A. Security predicate function

B. Database trigger

C. View

D. Stored procedure

Answer: A

Explanation: An inline table-valued predicate function evaluates each row and determines whether it should be returned.


Question 3

Which statement about Row-Level Security is correct?

A. It encrypts rows before storage.

B. It permanently removes unauthorized rows.

C. It automatically filters query results according to a security policy.

D. It masks sensitive column values.

Answer: C

Explanation: RLS evaluates a security policy during query execution and returns only authorized rows without modifying the stored data.


Question 4

Which type of security predicate prevents unauthorized INSERT, UPDATE, or DELETE operations?

A. Filter predicate

B. Access predicate

C. Security predicate

D. Block predicate

Answer: D

Explanation: Block predicates prevent users from performing unauthorized data modifications.


Question 5

Which function is commonly used in web applications to store tenant-specific information for Row-Level Security?

A. CURRENT_USER

B. SESSION_CONTEXT()

C. USER_ID()

D. DB_NAME()

Answer: B

Explanation: SESSION_CONTEXT() stores key-value pairs for the current session, making it ideal for multi-tenant applications.


Question 6

A developer creates the following policy:

ADD FILTER PREDICATE
Security.fn_FilterRegion(Region)
ON dbo.Sales;

What is the effect?

A. Rows are encrypted.

B. Columns are masked.

C. Unauthorized rows are automatically filtered from query results.

D. The table becomes read-only.

Answer: C

Explanation: A filter predicate restricts which rows are returned based on the predicate function.


Question 7

Which statement best describes the relationship between applications and Row-Level Security?

A. Applications must include special WHERE clauses.

B. Applications require encryption libraries.

C. Applications typically require no changes because SQL Server applies filtering automatically.

D. Applications cannot use SELECT * statements.

Answer: C

Explanation: RLS is transparent to applications. SQL Server automatically applies the filtering logic defined in the security policy.


Question 8

Which feature is most appropriate when users should see every row but sensitive values should be partially hidden?

A. Row-Level Security

B. Always Encrypted

C. Transparent Data Encryption

D. Dynamic Data Masking

Answer: D

Explanation: Dynamic Data Masking hides sensitive column values while still allowing users to access all authorized rows.


Question 9

Which statement is true regarding Row-Level Security?

A. It replaces authentication.

B. It determines which rows a user can access after authentication.

C. It encrypts the database backup.

D. It compresses tables.

Answer: B

Explanation: Authentication establishes the user’s identity, while RLS determines which rows that authenticated user is allowed to access.


Question 10

Which practice is recommended when designing Row-Level Security policies?

A. Use complex scalar functions to maximize flexibility.

B. Disable SCHEMABINDING to simplify maintenance.

C. Keep predicate functions simple and efficient to minimize performance overhead.

D. Place all filtering logic in application code instead of the database.

Answer: C

Explanation: Efficient predicate functions help reduce the performance impact of Row-Level Security while maintaining centralized, database-enforced access control.


Go to the DP-800 Exam Prep Hub main page

Design and implement Dynamic Data Masking (DDM) (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Design and implement Dynamic Data Masking


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

What is Dynamic Data Masking?

Dynamic Data Masking (DDM) is a SQL Server and Azure SQL feature that limits the exposure of sensitive data by masking the results returned to non-privileged users without modifying the actual data stored in the database.

Unlike encryption, DDM does not change or encrypt the stored data. Instead, SQL Server dynamically replaces sensitive values with masked values when queries are executed by users who do not have permission to view the original data.

For example, the database may contain:

CustomerNameSSNEmail
John Smith123-45-6789john@email.com

A privileged user sees:

CustomerNameSSNEmail
John Smith123-45-6789john@email.com

A non-privileged user may see:

CustomerNameSSNEmail
John SmithXXX-XX-6789jXXX@XXXX.com

The underlying data never changes.


Why Use Dynamic Data Masking?

Organizations frequently store sensitive information such as:

  • Personally Identifiable Information (PII)
  • Social Security Numbers
  • Credit card numbers
  • Email addresses
  • Phone numbers
  • Employee salaries
  • Medical information

Not every user who queries the database should have unrestricted access to these values.

DDM allows developers to:

  • Reduce accidental data exposure
  • Protect sensitive fields
  • Simplify application development
  • Support compliance initiatives
  • Allow customer support personnel to work with realistic-looking data

How Dynamic Data Masking Works

When a user executes a query:

  1. SQL Server checks whether the user has permission to view unmasked data.
  2. If the user has the UNMASK permission, actual values are returned.
  3. Otherwise, SQL Server substitutes masked values before sending the results.

The database itself remains unchanged.


Dynamic Data Masking Architecture

Database
├── Actual Data
│ 987-65-4321
├── User A
│ Has UNMASK permission
│ Result:
│ 987-65-4321
└── User B
No UNMASK permission
Result:
XXX-XX-4321

Benefits of Dynamic Data Masking

DDM provides several important advantages.

Easy to Implement

Masking is configured using T-SQL without requiring application changes.


No Data Duplication

The original data remains stored only once.


Transparent to Applications

Applications continue issuing the same queries.

No application code changes are required.


Supports Least Privilege

Users receive only the information they need.


Helps Meet Compliance Requirements

Although DDM is not encryption, it helps organizations reduce unnecessary exposure of sensitive information.


Dynamic Data Masking vs Encryption

Dynamic Data MaskingEncryption
Masks query resultsEncrypts stored data
Data remains unchangedData stored encrypted
Protects against accidental viewingProtects against data theft
Transparent to applicationsMay require encryption keys
Does not secure backupsProtects stored data

Microsoft expects candidates to understand that DDM is not a replacement for encryption technologies such as Always Encrypted or Transparent Data Encryption (TDE).


Supported Masking Functions

SQL Server supports several built-in masking functions.


Default Mask

Masks data according to its data type.

Example:

Original:

John Smith

Masked:

XXXX

Syntax:

MASKED WITH (FUNCTION = 'default()')

Email Mask

Designed specifically for email addresses.

Original:

john.smith@email.com

Masked:

jXXX@XXXX.com

Syntax:

MASKED WITH (FUNCTION = 'email()')

Partial Mask

Reveals part of a string while masking the remainder.

Example:

Original:

555-123-4567

Masked:

XXX-XXX-4567

Syntax:

MASKED WITH
(
FUNCTION='partial(prefix,padding,suffix)'
)

Example:

MASKED WITH
(
FUNCTION='partial(0,"XXX-XXX-",4)'
)

Random Mask

Returns a random value within a specified numeric range.

Example:

Original Salary

85000

Masked

43782

Syntax

MASKED WITH
(
FUNCTION='random(1,100000)'
)

Useful when exact values should never be exposed.


Creating a Masked Column

Example:

CREATE TABLE Customers
(
CustomerID INT,
Name NVARCHAR(100),
Email NVARCHAR(200)
MASKED WITH (FUNCTION='email()'),
SSN CHAR(11)
MASKED WITH
(
FUNCTION='partial(0,"XXX-XX-",4)'
)
);

Adding a Mask to an Existing Column

ALTER TABLE Customers
ALTER COLUMN Email
ADD MASKED
WITH (FUNCTION='email()');

Removing a Mask

ALTER TABLE Customers
ALTER COLUMN Email
DROP MASKED;

Granting UNMASK Permission

Privileged users may view actual values.

GRANT UNMASK TO HRManager;

Revoking Permission

REVOKE UNMASK FROM HRManager;

Viewing Mask Definitions

View masking metadata.

SELECT *
FROM sys.masked_columns;

Useful during administration and auditing.


DDM with Azure SQL Database

Dynamic Data Masking is fully supported in:

  • Azure SQL Database
  • Azure SQL Managed Instance
  • SQL Server

Azure SQL also provides portal-based configuration through the Azure Portal.

Developers can create masks without writing T-SQL.


Limitations of Dynamic Data Masking

Candidates should understand these limitations.

It Is Not Encryption

Anyone with sufficient permissions can retrieve actual values.


Database Administrators Can View Data

Members of powerful administrative roles can bypass masking.


Cannot Stop Inference Attacks

Users may infer values through repeated queries.


Not Intended for High-Security Scenarios

Highly confidential data should use:

  • Always Encrypted
  • Transparent Data Encryption
  • Row-Level Security
  • Proper access control

Expressions Return Masked Values

If a masked column is used in expressions, the expression also returns masked results for users without UNMASK permission.


Best Practices

Mask Only Sensitive Columns

Avoid unnecessary masking.


Combine with Other Security Features

Use together with:

  • Always Encrypted
  • Row-Level Security
  • Transparent Data Encryption
  • Microsoft Entra authentication
  • Least privilege access

Grant UNMASK Sparingly

Only trusted users should receive this permission.


Test Using Non-Privileged Accounts

Always verify what ordinary users actually see.


Audit Sensitive Access

Monitor who receives UNMASK permissions.


Dynamic Data Masking vs Row-Level Security

Dynamic Data MaskingRow-Level Security
Masks valuesFilters rows
User sees all rowsUser sees only authorized rows
Protects columnsProtects records
Works with SELECT resultsControls data visibility
Often used with RLSOften combined with DDM

DP-800 Exam Tips

Candidates should be able to:

  • Explain what Dynamic Data Masking is.
  • Differentiate masking from encryption.
  • Identify supported masking functions.
  • Create masked columns using CREATE TABLE and ALTER TABLE.
  • Grant and revoke the UNMASK permission.
  • Understand when DDM is appropriate.
  • Recognize DDM limitations.
  • Choose DDM versus Always Encrypted, TDE, or Row-Level Security based on the security requirement.
  • Understand that DDM protects against accidental exposure, not malicious users with elevated privileges.

Practice Exam Questions

Question 1

A company wants customer support representatives to view only partially masked Social Security numbers while allowing HR staff to view the full values.

Which SQL Server feature best meets this requirement?

A. Transparent Data Encryption

B. Dynamic Data Masking

C. Always Encrypted

D. Data Compression

Answer: B

Explanation: Dynamic Data Masking displays masked values to unauthorized users while allowing authorized users with the appropriate permissions to see the original data.


Question 2

Which statement about Dynamic Data Masking is true?

A. It encrypts data stored on disk.

B. It permanently changes stored values.

C. It masks query results for users without UNMASK permission.

D. It replaces encryption.

Answer: C

Explanation: Dynamic Data Masking only alters the data presented in query results. The stored values remain unchanged.


Question 3

Which masking function is specifically designed for email addresses?

A. partial()

B. random()

C. default()

D. email()

Answer: D

Explanation: The email() masking function preserves the general format of an email address while obscuring most of the information.


Question 4

Which statement best describes the partial() masking function?

A. It encrypts selected characters.

B. It returns random values.

C. It permanently replaces data.

D. It reveals specified prefix and suffix characters while masking the middle.

Answer: D

Explanation: The partial() function exposes configurable leading and trailing characters while masking the remaining portion of the value.


Question 5

Which permission allows a user to view unmasked data?

A. SELECT

B. CONTROL

C. UNMASK

D. VIEW DEFINITION

Answer: C

Explanation: Users granted the UNMASK permission can view the original values instead of the masked representations.


Question 6

Which system catalog view displays information about masked columns?

A. sys.columns

B. sys.masked_columns

C. sys.tables

D. sys.database_permissions

Answer: B

Explanation: The sys.masked_columns catalog view contains metadata about all columns configured with Dynamic Data Masking.


Question 7

A database administrator wants to protect highly confidential financial information from administrators who manage the database server.

Which technology should be preferred over Dynamic Data Masking?

A. Always Encrypted

B. Dynamic Data Masking

C. Partial masking

D. Random masking

Answer: A

Explanation: Always Encrypted ensures that sensitive data remains encrypted even from database administrators because encryption and decryption occur on the client side.


Question 8

Which statement about Dynamic Data Masking and application code is generally correct?

A. Applications must always be rewritten.

B. DDM requires client-side decryption.

C. Existing queries usually continue to work without modification.

D. Applications cannot access masked tables.

Answer: C

Explanation: Dynamic Data Masking is transparent to most applications, allowing existing queries to function normally while returning masked data when appropriate.


Question 9

A developer executes the following statement:

GRANT UNMASK TO SalesManager;

What is the effect?

A. The SalesManager can modify masked columns.

B. The SalesManager can bypass row-level security.

C. The SalesManager can view original values in masked columns, provided they also have permission to access the data.

D. All users inherit the UNMASK permission.

Answer: C

Explanation: The UNMASK permission allows a user to see unmasked values but does not grant access to data that the user is otherwise unauthorized to read.


Question 10

Which security strategy provides the strongest protection for sensitive database columns?

A. Use only Dynamic Data Masking.

B. Use only Row-Level Security.

C. Use only Transparent Data Encryption.

D. Combine Dynamic Data Masking with encryption, least-privilege access, and other SQL Server security features.

Answer: D

Explanation: Dynamic Data Masking is most effective as part of a layered security strategy that also includes encryption, access controls, auditing, and other SQL Server security features.


Go to the DP-800 Exam Prep Hub main page

Design and implement data encryption, including Always Encrypted and column-level encryption (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement data security and compliance
      --> Design and implement data encryption, including Always Encrypted and column-level encryption


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Data encryption is one of the most important security capabilities available in Microsoft SQL Server, Azure SQL Database, Azure SQL Managed Instance, and Microsoft Fabric SQL Database. Encryption helps protect sensitive information such as personally identifiable information (PII), financial records, healthcare data, passwords, and confidential business information from unauthorized access.

For the DP-800: Developing AI-Enabled Database Solutions exam, you should understand not only how to implement encryption, but also when to use different encryption technologies, their limitations, performance implications, and how they interact with applications.


Why Data Encryption Matters

Modern organizations must comply with regulations such as:

  • GDPR
  • HIPAA
  • PCI-DSS
  • SOC 2
  • ISO 27001

Encryption protects data against:

  • Database theft
  • Unauthorized administrators
  • Lost backups
  • Insider threats
  • Network interception

SQL Server provides multiple encryption technologies, each solving a different security problem.


SQL Server Encryption Technologies

Understanding which technology solves which problem is critical for the exam.

TechnologyProtectsData State
Transparent Data Encryption (TDE)Database files and backupsAt rest
Always EncryptedSensitive columns from DBAs and attackersIn use and at rest
Column-Level EncryptionIndividual columnsAt rest
TLS/SSLNetwork trafficIn transit
Dynamic Data MaskingPrevents accidental viewingQuery results
Row-Level SecurityLimits rows returnedQuery execution

Data at Rest vs Data in Transit vs Data in Use

A common exam objective is understanding these three states.

Data at Rest

Data stored on:

  • MDF files
  • LDF files
  • Backups
  • Storage disks

Protected using:

  • TDE
  • Column encryption
  • Always Encrypted

Data in Transit

Data traveling:

  • Client → SQL Server
  • SQL Server → Application

Protected using:

  • TLS (SSL)

Data in Use

Data currently being processed inside memory.

Only Always Encrypted protects sensitive data while SQL Server is processing queries.


Transparent Data Encryption (TDE)

Although the objective focuses on Always Encrypted and column-level encryption, you should understand how TDE differs.

TDE encrypts:

  • Database files
  • Log files
  • Backups

Advantages:

  • No application changes
  • Easy to enable
  • Minimal performance overhead

Limitations:

  • SQL Server decrypts data automatically.
  • Database administrators can still read data.

TDE protects storage—not the data itself from privileged users.


Column-Level Encryption

Column-level encryption encrypts specific columns inside a table.

Example:

CreditCardNumber
SocialSecurityNumber
Salary

Instead of encrypting the whole database, only selected columns are encrypted.


How Column-Level Encryption Works

SQL Server uses encryption functions such as:

  • ENCRYPTBYKEY
  • DECRYPTBYKEY
  • ENCRYPTBYPASSPHRASE
  • DECRYPTBYPASSPHRASE

Example:

OPEN SYMMETRIC KEY CustomerKey
DECRYPTION BY CERTIFICATE CustomerCert;
UPDATE Customers
SET SSN =
ENCRYPTBYKEY(KEY_GUID('CustomerKey'), '123-45-6789');

Reading data:

SELECT
CONVERT(varchar,
DECRYPTBYKEY(SSN))
FROM Customers;

Encryption Hierarchy

SQL Server uses multiple encryption layers.

Service Master Key
Database Master Key
Certificate
Symmetric Key
Encrypted Column

Each level protects the one below it.


Symmetric Encryption

Uses one key for both:

  • Encryption
  • Decryption

Advantages

  • Fast
  • Efficient
  • Best for large datasets

Example

Encrypt → Key A
Decrypt → Key A

Asymmetric Encryption

Uses:

  • Public key
  • Private key

Advantages

  • Strong security
  • Digital signatures

Disadvantages

  • Slower

Usually used to protect symmetric keys.


Certificates

Certificates often protect symmetric keys.

Example:

Certificate
Protects Symmetric Key
Encrypts Customer Data

Always Encrypted

Always Encrypted is one of the most important DP-800 topics.

Unlike traditional encryption:

SQL Server never sees the plaintext values.

Encryption occurs inside the client application.


Why Always Encrypted Exists

Imagine a database administrator with full access.

With normal encryption:

  • DBA can decrypt data.

With Always Encrypted:

  • DBA cannot read encrypted values.

Only authorized client applications possess the encryption keys.


How Always Encrypted Works

Application
Encrypt value
SQL Server stores ciphertext
Application retrieves ciphertext
Application decrypts

SQL Server never performs decryption.


Benefits

Protects against:

  • Curious administrators
  • Database theft
  • Backup theft
  • Cloud administrators
  • Insider attacks

Key Components

Always Encrypted uses two key types.

Column Master Key (CMK)

Stored outside SQL Server.

Examples:

  • Windows Certificate Store
  • Azure Key Vault
  • Hardware Security Module (HSM)

Purpose:

Protects Column Encryption Keys.


Column Encryption Key (CEK)

Stored inside SQL Server.

Purpose:

Encrypts actual column values.

Hierarchy:

CMK
CEK
Encrypted Data

Deterministic Encryption

Always produces the same ciphertext for identical values.

Example

"Florida"
A91BCD
"Florida"
A91BCD

Advantages

Supports:

  • Equality searches
  • Joins
  • GROUP BY
  • Indexes

Disadvantages

Repeated values are recognizable.


Randomized Encryption

Produces different ciphertext every time.

Example

Florida
A91BCD
Florida
XYZ123

Advantages

Maximum security.

Disadvantages

Cannot perform:

  • Equality comparisons
  • JOIN
  • GROUP BY
  • Index lookups

Deterministic vs Randomized

FeatureDeterministicRandomized
Highest securityNoYes
Equality searchYesNo
JOINYesNo
GROUP BYYesNo
Index seekYesNo

Creating a Column Master Key

Example:

CREATE COLUMN MASTER KEY CMK1
WITH
(
KEY_STORE_PROVIDER_NAME =
'MSSQL_CERTIFICATE_STORE',
KEY_PATH =
'CurrentUser/My/123456789'
);

Creating a Column Encryption Key

CREATE COLUMN ENCRYPTION KEY CEK1
WITH VALUES
(
COLUMN_MASTER_KEY = CMK1,
ALGORITHM = 'RSA_OAEP',
ENCRYPTED_VALUE = ...
);

Encrypting a Column

CREATE TABLE Customers
(
CustomerID INT,
SSN CHAR(11)
COLLATE Latin1_General_BIN2
ENCRYPTED WITH
(
COLUMN_ENCRYPTION_KEY = CEK1,
ENCRYPTION_TYPE = DETERMINISTIC,
ALGORITHM =
'AEAD_AES_256_CBC_HMAC_SHA_256'
)
);

Secure Enclaves

Always Encrypted originally limited many SQL operations.

Secure Enclaves improve functionality by allowing protected computations within a secure hardware-based memory region.

Benefits:

  • Richer comparisons
  • Pattern matching
  • Range queries
  • In-place encryption
  • Better performance

Limitations of Always Encrypted

Developers should understand these limitations.

Not all SQL operations are supported.

Some restrictions include:

  • LIKE (without enclaves)
  • Pattern matching
  • Sorting randomized columns
  • Range comparisons
  • Certain aggregates
  • Some conversions

Client Driver Requirements

Always Encrypted requires supported drivers.

Examples:

  • Microsoft.Data.SqlClient
  • .NET Framework
  • ODBC Driver
  • JDBC Driver

Client drivers perform:

  • Encryption
  • Decryption
  • Key retrieval

Azure Key Vault Integration

A common enterprise deployment stores Column Master Keys inside Azure Key Vault.

Benefits:

  • Centralized key management
  • Hardware-backed security
  • Automatic auditing
  • Key rotation
  • Separation of duties

Performance Considerations

Always Encrypted introduces overhead because:

  • Client encrypts data
  • Client decrypts data
  • Keys must be managed
  • Network payloads increase

However, it provides much stronger protection than standard encryption.


Best Practices

Microsoft recommends:

  • Encrypt only sensitive columns.
  • Store CMKs outside SQL Server.
  • Use Azure Key Vault when possible.
  • Use deterministic encryption only when querying is required.
  • Use randomized encryption for maximum confidentiality.
  • Rotate encryption keys regularly.
  • Use TLS together with Always Encrypted.
  • Monitor application performance after enabling encryption.
  • Test query compatibility before production deployment.

DP-800 Exam Tips

Be prepared to distinguish:

  • TDE vs Always Encrypted
  • Column-Level Encryption vs Always Encrypted
  • Deterministic vs Randomized encryption
  • CMK vs CEK
  • Encryption at rest vs in transit vs in use
  • Azure Key Vault integration
  • Secure Enclaves
  • Encryption hierarchy
  • Performance implications
  • Client-side versus server-side encryption

Practice Exam Questions

Question 1

A company wants to ensure that database administrators cannot view customers’ Social Security numbers while still allowing applications to access the data. Which encryption technology should be implemented?

A. Transparent Data Encryption (TDE)

B. Dynamic Data Masking

C. Row-Level Security

D. Always Encrypted

Answer: D

Explanation: Always Encrypted performs encryption and decryption on the client side, preventing SQL Server and database administrators from viewing plaintext data.


Question 2

Which key encrypts the actual column data in Always Encrypted?

A. Column Encryption Key

B. Database Master Key

C. Service Master Key

D. Column Master Key

Answer: A

Explanation: The Column Encryption Key (CEK) encrypts the column values. The Column Master Key (CMK) protects the CEK.


Question 3

Which encryption type should you choose if users must frequently search by exact Social Security number?

A. Randomized encryption

B. Transparent Data Encryption

C. Deterministic encryption

D. Dynamic Data Masking

Answer: C

Explanation: Deterministic encryption produces the same ciphertext for identical values, enabling equality searches and index usage.


Question 4

Which SQL Server feature encrypts entire database files and backup files without requiring application changes?

A. Always Encrypted

B. Column-Level Encryption

C. Dynamic Data Masking

D. Transparent Data Encryption

Answer: D

Explanation: Transparent Data Encryption (TDE) encrypts database and backup files, protecting data at rest.


Question 5

Where is the Column Master Key typically stored?

A. Azure Storage Account

B. SQL Server system database

C. TempDB

D. Azure Key Vault or Windows Certificate Store

Answer: D

Explanation: Microsoft recommends storing Column Master Keys outside SQL Server, commonly in Azure Key Vault or the Windows Certificate Store.


Question 6

Which encryption method provides the highest confidentiality for sensitive columns?

A. Deterministic encryption

B. Randomized encryption

C. Transparent Data Encryption

D. TLS encryption

Answer: B

Explanation: Randomized encryption produces different ciphertext for identical values, making frequency analysis much more difficult.


Question 7

A developer wants to encrypt only the CreditCardNumber column while leaving the remainder of the table unchanged. Which approach is most appropriate?

A. Column-Level Encryption

B. Transparent Data Encryption

C. Database snapshots

D. Always On Availability Groups

Answer: A

Explanation: Column-level encryption targets individual columns rather than the entire database.


Question 8

Which SQL Server feature enhances Always Encrypted by allowing additional query operations on encrypted columns?

A. Secure Enclaves

B. Dynamic Data Masking

C. PolyBase

D. Stretch Database

Answer: A

Explanation: Secure Enclaves enable richer computations on encrypted data, including some range and pattern-matching operations.


Question 9

Which data state is protected by TLS encryption?

A. Data at rest

B. Data in transit

C. Data in use

D. Archived data

Answer: B

Explanation: TLS encrypts network communications between clients and SQL Server, protecting data while it is being transmitted.


Question 10

Why is Always Encrypted considered more secure than traditional column-level encryption?

A. It automatically compresses encrypted data.

B. It encrypts entire databases.

C. SQL Server never has access to plaintext values because encryption occurs on the client side.

D. It eliminates the need for encryption keys.

Answer: C

Explanation: Always Encrypted keeps encryption keys and plaintext data outside SQL Server, ensuring that even highly privileged users cannot view sensitive information.


Go to the DP-800 Exam Prep Hub main page

Connect to MCP server endpoints, including Microsoft SQL Server and Fabric lakehouse (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Design and develop database solutions (35–40%)
   --> Design and implement SQL solutions by using AI-assisted tools
      --> Connect to MCP server endpoints, including Microsoft SQL Server and Fabric lakehouse


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

As AI-powered development tools continue to evolve, developers increasingly need AI assistants that can interact with live enterprise systems rather than relying solely on the knowledge contained within large language models. The Model Context Protocol (MCP) provides a standardized way for AI assistants, such as GitHub Copilot and Microsoft Copilot, to securely connect to external tools, databases, services, and applications.

For DP-800 candidates, understanding how MCP enables AI-assisted database development is becoming increasingly important. Rather than simply generating SQL code, AI assistants can use MCP to retrieve database metadata, inspect schemas, execute approved queries, explore Fabric Lakehouse data, and assist with troubleshooting in real time.

This article explains how MCP works, how to connect to MCP server endpoints, common use cases involving Microsoft SQL Server and Microsoft Fabric Lakehouse, and best practices for secure implementation.


Learning Objectives

After studying this topic, you should be able to:

  • Understand the purpose of the Model Context Protocol (MCP)
  • Explain the relationship between AI clients and MCP servers
  • Describe how GitHub Copilot and Microsoft Copilot use MCP
  • Connect AI assistants to SQL Server MCP endpoints
  • Connect AI assistants to Microsoft Fabric Lakehouse MCP endpoints
  • Understand authentication and authorization requirements
  • Follow security best practices
  • Troubleshoot common MCP connection issues

What is the Model Context Protocol (MCP)?

The Model Context Protocol (MCP) is an open protocol that standardizes communication between AI applications and external systems.

Instead of building custom integrations for every database or service, AI clients communicate with MCP servers using a consistent protocol.

Think of MCP as a standardized “USB-C connector” for AI applications.

Without MCP:

AI Client
|
Custom SQL Connector
Custom Fabric Connector
Custom REST Connector
Custom File Connector

With MCP:

AI Client
|
MCP
|
-------------------------------------
SQL Server
Fabric Lakehouse
REST APIs
Files
GitHub
Azure Services

This standardized approach simplifies integration while improving maintainability and interoperability.


Why MCP Matters

Traditional AI coding assistants only generate code based on:

  • User prompts
  • Training data
  • Conversation history

Using MCP, AI assistants can also access:

  • Database schemas
  • Table definitions
  • Views
  • Stored procedures
  • Lakehouse metadata
  • Files
  • Documentation
  • Business knowledge
  • External APIs

This enables AI to generate more accurate, context-aware responses.


MCP Architecture

An MCP solution consists of three primary components.

MCP Client

The MCP client is the AI application.

Examples include:

  • GitHub Copilot
  • Microsoft Copilot
  • Visual Studio Code
  • Visual Studio
  • Other MCP-compatible AI assistants

The client sends requests to one or more MCP servers.


MCP Server

The MCP server exposes tools and resources that AI assistants can access.

Examples:

  • SQL Server
  • Fabric Lakehouse
  • Azure services
  • GitHub repositories
  • File systems
  • REST APIs

The server determines which operations are available.


Resource or Tool

Resources exposed by an MCP server may include:

  • Database tables
  • Views
  • Stored procedures
  • SQL execution tools
  • Schema information
  • Lakehouse metadata
  • Documentation
  • APIs

MCP Communication Flow

A typical workflow is:

Developer
GitHub Copilot
MCP Server
SQL Server
Results
GitHub Copilot
Developer

The AI assistant acts as the intermediary, translating user requests into approved tool invocations.


Connecting to an MCP Server

Connecting to an MCP server typically involves:

  1. Configuring the AI client
  2. Registering the MCP endpoint
  3. Authenticating
  4. Discovering available tools
  5. Authorizing access
  6. Using the available resources

Authentication

Authentication verifies the identity of the user or application.

Common authentication methods include:

  • Microsoft Entra ID
  • OAuth
  • Personal Access Tokens (PATs)
  • API Keys (less common)
  • Managed Identity (Azure-hosted scenarios)

Authentication occurs before any tool or data is accessed.


Authorization

Authorization determines what operations the AI may perform.

For example:

Allowed:

  • Read schema
  • Execute SELECT statements
  • View metadata

Denied:

  • DROP TABLE
  • DELETE production data
  • ALTER DATABASE

Least privilege remains an essential security principle.


Connecting to Microsoft SQL Server

An SQL Server MCP server exposes database capabilities to AI assistants.

Common resources include:

  • Tables
  • Views
  • Stored procedures
  • Functions
  • Database metadata
  • Execution plans
  • Query execution tools

Example workflow:

Developer asks:

Show me the Sales schema.

Copilot sends an MCP request.

SQL Server returns:

  • Tables
  • Columns
  • Relationships

Copilot explains the schema.


SQL Server MCP Use Cases

Examples include:

Schema Discovery

Instead of guessing table names:

Copilot retrieves:

  • Customers
  • Orders
  • Products
  • Sales

The generated SQL becomes much more accurate.


Generate SQL

Developer:

Show total revenue by country.

Copilot:

  • Reads schema
  • Finds relationships
  • Generates correct JOIN statements

Explain Stored Procedures

Developer:

Explain usp_ProcessOrders.

Copilot retrieves:

  • Procedure definition
  • Parameters
  • Business logic

Then provides a detailed explanation.


Query Optimization

Copilot can:

  • Inspect indexes
  • Analyze execution plans
  • Suggest rewrites
  • Recommend indexing improvements

Connecting to Microsoft Fabric Lakehouse

Fabric Lakehouse combines:

  • Data Lake
  • Data Warehouse
  • Spark
  • Delta tables

Using MCP, Copilot can interact with Lakehouse metadata.

Available resources may include:

  • Delta tables
  • Shortcuts
  • SQL endpoint metadata
  • Semantic information
  • OneLake structure

Fabric Lakehouse Use Cases

Examples include:

Discover Tables

Developer:

List all sales tables.

Copilot queries metadata.


Generate SQL Analytics Queries

Developer:

Calculate monthly sales growth.

Copilot examines available tables.

Generates optimized SQL.


Explain Lakehouse Structure

Developer:

Explain this Lakehouse.

Copilot can describe:

  • Schemas
  • Delta tables
  • Relationships
  • Storage organization

Data Exploration

Developers can ask:

  • Which tables contain customer data?
  • Which columns contain dates?
  • Which datasets contain revenue?

MCP Tool Discovery

One advantage of MCP is automatic discovery.

After connecting, Copilot can identify available tools such as:

  • Execute SQL
  • Read schema
  • Read documentation
  • Search metadata
  • Retrieve files

The user does not need to manually configure every capability.


Multiple MCP Servers

An AI assistant may connect to multiple MCP servers simultaneously.

Example:

GitHub Copilot
├── SQL Server MCP
├── Fabric Lakehouse MCP
├── GitHub MCP
├── Azure MCP
└── Documentation MCP

This allows a single conversation to span multiple enterprise systems.


Security Considerations

Organizations should never allow unrestricted AI access to production databases.

Best practices include:

  • Read-only access whenever possible
  • Least privilege permissions
  • Entra ID authentication
  • Audit logging
  • Approval workflows for sensitive actions
  • Data classification awareness
  • Secure network connectivity
  • Encryption in transit
  • Regular permission reviews

Network Considerations

Successful MCP connections require:

  • Network connectivity
  • Firewall configuration
  • DNS resolution
  • TLS encryption
  • Endpoint availability

Connection failures often result from blocked network paths or invalid authentication.


Common Connection Issues

Common problems include:

Authentication Failure

Possible causes:

  • Expired token
  • Invalid credentials
  • Missing permissions

Authorization Failure

The user authenticates successfully but lacks permission to use a tool.


Endpoint Unavailable

Possible causes:

  • Incorrect URL
  • Server offline
  • Network outage

Firewall Restrictions

Corporate firewalls may block communication.


Tool Discovery Failure

Possible causes:

  • Unsupported MCP version
  • Server configuration issues
  • Missing capabilities

Best Practices

Microsoft recommends:

  • Connect only trusted MCP servers.
  • Use Microsoft Entra ID when available.
  • Apply least privilege permissions.
  • Validate AI-generated SQL before execution.
  • Audit AI tool usage.
  • Separate development and production environments.
  • Monitor server logs.
  • Keep MCP server software updated.
  • Limit write operations unless required.
  • Review AI responses for correctness before acting on them.

SQL Server vs. Fabric Lakehouse MCP Connections

FeatureSQL Server MCPFabric Lakehouse MCP
Primary purposeRelational databasesLakehouse analytics
ObjectsTables, views, proceduresDelta tables, SQL endpoints
Typical queriesOLTP and reportingAnalytics and big data
MetadataDatabase schemasLakehouse metadata
AI assistanceSQL generation, optimizationAnalytics, exploration, SQL generation

DP-800 Exam Tips

For the exam, remember these key points:

  • MCP is a standardized protocol for connecting AI applications to external tools and data sources.
  • GitHub Copilot and Microsoft Copilot can use MCP servers to access live enterprise resources.
  • SQL Server MCP servers expose relational database metadata and tools.
  • Fabric Lakehouse MCP servers expose Lakehouse metadata, Delta tables, and analytics resources.
  • Authentication verifies identity; authorization determines permitted actions.
  • AI assistants should operate with least privilege.
  • Developers remain responsible for validating all AI-generated code and database operations.
  • Organizations should use secure authentication, auditing, and network protections when deploying MCP-enabled AI solutions.

Summary

The Model Context Protocol (MCP) provides a standardized framework for connecting AI assistants with enterprise resources such as Microsoft SQL Server and Microsoft Fabric Lakehouse. By using MCP, GitHub Copilot and Microsoft Copilot can retrieve live metadata, understand database schemas, generate more accurate SQL, explain existing database objects, and assist with analytics. Proper authentication, authorization, auditing, and adherence to least privilege principles ensure that these powerful capabilities are implemented securely. As AI-assisted database development becomes more prevalent, understanding MCP connectivity and governance is an important skill for DP-800 candidates.


Practice Exam Questions

Question 1

A development team wants GitHub Copilot to retrieve SQL Server table definitions before generating SQL queries. Which technology enables this standardized communication?

A. SQL Server Integration Services (SSIS)

B. Model Context Protocol (MCP)

C. Open Database Connectivity (ODBC)

D. SQL Server Agent

Answer: B

Explanation: MCP provides a standardized protocol that enables AI clients to communicate with external systems such as SQL Server.


Question 2

What is the primary role of an MCP server?

A. Execute operating system updates

B. Store AI model weights

C. Expose tools and resources that AI clients can access

D. Replace Microsoft Entra ID authentication

Answer: C

Explanation: An MCP server exposes resources such as database schemas, SQL execution tools, documentation, and APIs to compatible AI clients.


Question 3

Which authentication mechanism is most commonly recommended for connecting GitHub Copilot to enterprise MCP servers?

A. Anonymous authentication

B. Basic authentication with shared passwords

C. FTP credentials

D. Microsoft Entra ID

Answer: D

Explanation: Microsoft Entra ID provides secure, enterprise-grade authentication with support for modern identity management.


Question 4

An AI assistant successfully authenticates to an SQL Server MCP endpoint but cannot execute a query because of insufficient permissions. Which security concept is responsible?

A. Encryption

B. Compression

C. Authorization

D. Serialization

Answer: C

Explanation: Authentication confirms identity, while authorization determines what actions an authenticated user is permitted to perform.


Question 5

Which capability is most likely exposed by a Microsoft SQL Server MCP server?

A. Reading database schema metadata

B. Azure virtual machine creation

C. Configuring Microsoft Teams

D. Managing Windows updates

Answer: A

Explanation: SQL Server MCP servers commonly expose database metadata, tables, views, stored procedures, and SQL execution tools.


Question 6

Why would an organization use least privilege when configuring MCP server access?

A. To minimize security risks by limiting allowed operations

B. To increase database storage capacity

C. To improve AI response speed

D. To reduce SQL Server licensing costs

Answer: A

Explanation: Least privilege ensures AI assistants receive only the permissions necessary to perform approved tasks.


Question 7

Which Fabric resource is most commonly explored through a Fabric Lakehouse MCP server?

A. Windows Registry

B. Delta tables and Lakehouse metadata

C. DNS records

D. Azure Firewall rules

Answer: B

Explanation: Fabric Lakehouse MCP servers expose Lakehouse metadata, Delta tables, SQL endpoints, and related analytics resources.


Question 8

A developer asks Copilot, “List every customer table in my Lakehouse.” What is the AI assistant most likely doing?

A. Guessing based on its training data

B. Downloading the entire database

C. Using an MCP server to retrieve live metadata

D. Reading Windows Event Logs

Answer: C

Explanation: MCP allows AI assistants to query live metadata rather than relying solely on pretrained knowledge.


Question 9

What is one major advantage of connecting GitHub Copilot to multiple MCP servers?

A. It permanently stores database credentials.

B. It allows a single AI conversation to access multiple enterprise systems and tools.

C. It eliminates the need for authentication.

D. It replaces source control systems.

Answer: B

Explanation: Multiple MCP servers enable AI assistants to work across databases, repositories, documentation, APIs, and other enterprise resources within one workflow.


Question 10

Which statement best reflects Microsoft’s guidance regarding AI-assisted database operations through MCP?

A. AI-generated SQL should be executed automatically without review.

B. Production databases should always grant AI assistants full administrative permissions.

C. MCP eliminates the need for database security controls.

D. Developers should review AI-generated code and queries before executing them.

Answer: D

Explanation: Although MCP provides rich contextual information, developers remain responsible for validating AI-generated code, ensuring correctness, security, and compliance before deployment or execution.


Go to the DP-800 Exam Prep Hub main page