Gets a list of database data masking rules.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/Default/rules?api-version=2014-04-01
URI Parameters
Name |
In |
Required |
Type |
Description |
databaseName
|
path |
True
|
string
|
The name of the database.
|
dataMaskingPolicyName
|
path |
True
|
DataMaskingPolicyName
|
The name of the database for which the data masking rule applies.
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
|
serverName
|
path |
True
|
string
|
The name of the server.
|
subscriptionId
|
path |
True
|
string
|
The subscription ID that identifies an Azure subscription.
|
api-version
|
query |
True
|
string
|
The API version to use for the request.
|
Responses
Examples
List data masking rules
Sample request
GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-2080/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules?api-version=2014-04-01
import com.azure.core.util.Context;
/** Samples for DataMaskingRules ListByDatabase. */
public final class Main {
/*
* x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleList.json
*/
/**
* Sample code: List data masking rules.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void listDataMaskingRules(com.azure.resourcemanager.AzureResourceManager azure) {
azure
.sqlServers()
.manager()
.serviceClient()
.getDataMaskingRules()
.listByDatabase("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python data_masking_rule_list.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-1111-2222-3333-444444444444",
)
response = client.data_masking_rules.list_by_database(
resource_group_name="sqlcrudtest-6852",
server_name="sqlcrudtest-2080",
database_name="sqlcrudtest-331",
)
for item in response:
print(item)
# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleList.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armsql_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a3913f4b26467aed413cdc907116e99894f08994/specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleList.json
func ExampleDataMaskingRulesClient_NewListByDatabasePager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsql.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewDataMaskingRulesClient().NewListByDatabasePager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.DataMaskingRuleListResult = armsql.DataMaskingRuleListResult{
// Value: []*armsql.DataMaskingRule{
// {
// Type: to.Ptr("Microsoft.Sql/servers/databases/dataMaskingPolicies/rules"),
// ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/"),
// Location: to.Ptr("Central US"),
// Properties: &armsql.DataMaskingRuleProperties{
// ColumnName: to.Ptr("test1"),
// ID: to.Ptr("dbo_Table_1_test1"),
// MaskingFunction: to.Ptr(armsql.DataMaskingFunctionText),
// PrefixSize: to.Ptr("1"),
// ReplacementString: to.Ptr("asdf"),
// RuleState: to.Ptr(armsql.DataMaskingRuleStateEnabled),
// SchemaName: to.Ptr("dbo"),
// SuffixSize: to.Ptr("0"),
// TableName: to.Ptr("Table_1"),
// },
// },
// {
// Type: to.Ptr("Microsoft.Sql/servers/databases/dataMaskingPolicies/rules"),
// ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/"),
// Location: to.Ptr("Central US"),
// Properties: &armsql.DataMaskingRuleProperties{
// ColumnName: to.Ptr("test1"),
// ID: to.Ptr("dbo_Table_1_test1"),
// MaskingFunction: to.Ptr(armsql.DataMaskingFunctionNumber),
// NumberFrom: to.Ptr("0"),
// NumberTo: to.Ptr("2"),
// RuleState: to.Ptr(armsql.DataMaskingRuleStateEnabled),
// SchemaName: to.Ptr("dbo"),
// TableName: to.Ptr("Table_1"),
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets a list of database data masking rules.
*
* @summary Gets a list of database data masking rules.
* x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleList.json
*/
async function listDataMaskingRules() {
const subscriptionId =
process.env["SQL_SUBSCRIPTION_ID"] || "00000000-1111-2222-3333-444444444444";
const resourceGroupName = process.env["SQL_RESOURCE_GROUP"] || "sqlcrudtest-6852";
const serverName = "sqlcrudtest-2080";
const databaseName = "sqlcrudtest-331";
const credential = new DefaultAzureCredential();
const client = new SqlManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.dataMaskingRules.listByDatabase(
resourceGroupName,
serverName,
databaseName,
)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleList.json
// this example is just showing the usage of "DataMaskingRules_List" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this DataMaskingPolicyResource created on azure
// for more information of creating DataMaskingPolicyResource, please refer to the document of DataMaskingPolicyResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "sqlcrudtest-6852";
string serverName = "sqlcrudtest-2080";
string databaseName = "sqlcrudtest-331";
ResourceIdentifier dataMaskingPolicyResourceId = DataMaskingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId);
// invoke the operation and iterate over the result
await foreach (DataMaskingRule item in dataMaskingPolicy.GetDataMaskingRulesAsync())
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/",
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"location": "Central US",
"kind": null,
"properties": {
"id": "dbo_Table_1_test1",
"ruleState": "Enabled",
"schemaName": "dbo",
"tableName": "Table_1",
"columnName": "test1",
"aliasName": null,
"maskingFunction": "Text",
"numberFrom": null,
"numberTo": null,
"prefixSize": "1",
"suffixSize": "0",
"replacementString": "asdf"
}
},
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/",
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"location": "Central US",
"kind": null,
"properties": {
"id": "dbo_Table_1_test1",
"ruleState": "Enabled",
"schemaName": "dbo",
"tableName": "Table_1",
"columnName": "test1",
"aliasName": null,
"maskingFunction": "Number",
"numberFrom": "0",
"numberTo": "2",
"prefixSize": null,
"suffixSize": null,
"replacementString": null
}
}
]
}
Definitions
Name |
Description |
DataMaskingFunction
|
The masking function that is used for the data masking rule.
|
DataMaskingPolicyName
|
The name of the database for which the data masking rule applies.
|
DataMaskingRule
|
Represents a database data masking rule.
|
DataMaskingRuleListResult
|
The response to a list data masking rules request.
|
DataMaskingRuleState
|
The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState.
|
DataMaskingFunction
The masking function that is used for the data masking rule.
Name |
Type |
Description |
CCN
|
string
|
|
Default
|
string
|
|
Email
|
string
|
|
Number
|
string
|
|
SSN
|
string
|
|
Text
|
string
|
|
DataMaskingPolicyName
The name of the database for which the data masking rule applies.
Name |
Type |
Description |
Default
|
string
|
|
DataMaskingRule
Represents a database data masking rule.
Name |
Type |
Description |
id
|
string
|
Resource ID.
|
kind
|
string
|
The kind of Data Masking Rule. Metadata, used for Azure portal.
|
location
|
string
|
The location of the data masking rule.
|
name
|
string
|
Resource name.
|
properties.aliasName
|
string
|
The alias name. This is a legacy parameter and is no longer used.
|
properties.columnName
|
string
|
The column name on which the data masking rule is applied.
|
properties.id
|
string
|
The rule Id.
|
properties.maskingFunction
|
DataMaskingFunction
|
The masking function that is used for the data masking rule.
|
properties.numberFrom
|
string
|
The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored.
|
properties.numberTo
|
string
|
The numberTo property of the data masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored.
|
properties.prefixSize
|
string
|
If maskingFunction is set to Text, the number of characters to show unmasked in the beginning of the string. Otherwise, this parameter will be ignored.
|
properties.replacementString
|
string
|
If maskingFunction is set to Text, the character to use for masking the unexposed part of the string. Otherwise, this parameter will be ignored.
|
properties.ruleState
|
DataMaskingRuleState
|
The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState.
|
properties.schemaName
|
string
|
The schema name on which the data masking rule is applied.
|
properties.suffixSize
|
string
|
If maskingFunction is set to Text, the number of characters to show unmasked at the end of the string. Otherwise, this parameter will be ignored.
|
properties.tableName
|
string
|
The table name on which the data masking rule is applied.
|
type
|
string
|
Resource type.
|
DataMaskingRuleListResult
The response to a list data masking rules request.
Name |
Type |
Description |
value
|
DataMaskingRule[]
|
The list of database data masking rules.
|
DataMaskingRuleState
The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState.
Name |
Type |
Description |
Disabled
|
string
|
|
Enabled
|
string
|
|