Configure Data Masking in Azure SQL Database

45 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Learn how to assign the various types of data masks to fields in an Azure SQL Database. This important task will provide an additional layer of protection to your data.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create and Configure a SQL Database

Create a Standard edition SQL Database with 10 DTUs. You will need to create a SQL Server as well. Use any unique name desired and create in the Central US region. Enable the sample database and update the firewall rules for access.

Apply Data Mask Rules

Create an email mask for all customer emails. Create a masking scheme that masks all but the first letter of clients last names. Finally, create a complete mask for customer phone.

Once masking rules are complete create a test user login and confirm proper function.

Additional Resources


You work for a local Retail chain managing client data. In the wake of some internal audits it has been determined that there is a need for data masking on client databases used in marketing.

You have been tasked with implementing a masking solution that meets the following requirements:

  • Provide a masking scheme that masks all but the first letter of clients last names
  • Provide an Email mask for customer email address
  • Provide a complete mask for customer phone.

Finally, create a test user and log in to confirm proper function.


  • Log in to the live environment with the provided Azure Labs credentials.
  • Create a SQL Databases
    • Standard 10 DTUs ○ SQL Server (use a unique name) ○ East US region ○ Enable sample database
  • Create a user to test Data Mask in Azure Data Studio using this query: CREATE USER TestUser WITHOUT LOGIN;
    GRANT SELECT ON SalesLT.Customer TO TestUser;
  • Configure masks as described in scenario requirements
  • Test Data Mask in Azure Data Studio using the created user: EXECUTE AS USER = 'TestUser';
    SELECT * FROM SalesLT.Customer;


  • To Install Azure Data Studio download from Microsoft:

For detailed instructions on how to complete these tasks, expand each learning objective below, or click the Guide tab above the video player.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?