A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.microsoft.com/en-us/rest/api/sql/data-masking-rules/create-or-update below:

Data Masking Rules - Create Or Update - REST API (Azure SQL Database)

Data Masking Rules - Create Or Update

Creates or updates a database data masking rule.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/Default/rules/{dataMaskingRuleName}?api-version=2023-08-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 policy applies.

dataMaskingRuleName

path True

string

The name of the data masking rule.

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.

Request Body Name Required Type Description properties.columnName True

string

The column name on which the data masking rule is applied.

properties.maskingFunction True

DataMaskingFunction

The masking function that is used for the data masking rule.

properties.schemaName True

string

The schema name on which the data masking rule is applied.

properties.tableName True

string

The table name on which the data masking rule is applied.

properties.aliasName

string

The alias name. This is a legacy parameter and is no longer used.

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.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.

Responses Name Type Description 200 OK

DataMaskingRule

Successfully set a database data masking rule.

201 Created

DataMaskingRule

Successfully created a database data masking rule.

Other Status Codes

ErrorResponse

*** Error Responses: ***

Examples Create/Update data masking rule for default max. Sample request
PUT 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/rule1?api-version=2023-08-01

{
  "properties": {
    "aliasName": "nickname",
    "schemaName": "dbo",
    "tableName": "Table_1",
    "columnName": "test1",
    "maskingFunction": "Default",
    "ruleState": "Enabled"
  }
}

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/2023-08-01/examples/DataMaskingRuleCreateOrUpdateDefaultMax.json
// this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" 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";
DataMaskingPolicyName dataMaskingPolicyName = DataMaskingPolicyName.Default;
ResourceIdentifier dataMaskingPolicyResourceId = DataMaskingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, dataMaskingPolicyName);
DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId);

// invoke the operation
string dataMaskingRuleName = "rule1";
DataMaskingRule dataMaskingRule = new DataMaskingRule
{
    RuleState = DataMaskingRuleState.Enabled,
    SchemaName = "dbo",
    TableName = "Table_1",
    ColumnName = "test1",
    AliasName = "nickname",
    MaskingFunction = DataMaskingFunction.Default,
};
DataMaskingRule result = await dataMaskingPolicy.CreateOrUpdateDataMaskingRuleAsync(dataMaskingRuleName, dataMaskingRule);

Console.WriteLine($"Succeeded: {result}");

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
{
  "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": "nickname",
    "maskingFunction": "Default",
    "numberFrom": null,
    "numberTo": null,
    "prefixSize": null,
    "suffixSize": null,
    "replacementString": null
  }
}
{
  "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": "nickname",
    "maskingFunction": "Default",
    "numberFrom": null,
    "numberTo": null,
    "prefixSize": null,
    "suffixSize": null,
    "replacementString": null
  }
}
Create/Update data masking rule for default min. Sample request
PUT 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/rule1?api-version=2023-08-01

{
  "properties": {
    "schemaName": "dbo",
    "tableName": "Table_1",
    "columnName": "test1",
    "maskingFunction": "Default"
  }
}

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/2023-08-01/examples/DataMaskingRuleCreateOrUpdateDefaultMin.json
// this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" 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";
DataMaskingPolicyName dataMaskingPolicyName = DataMaskingPolicyName.Default;
ResourceIdentifier dataMaskingPolicyResourceId = DataMaskingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, dataMaskingPolicyName);
DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId);

// invoke the operation
string dataMaskingRuleName = "rule1";
DataMaskingRule dataMaskingRule = new DataMaskingRule
{
    SchemaName = "dbo",
    TableName = "Table_1",
    ColumnName = "test1",
    MaskingFunction = DataMaskingFunction.Default,
};
DataMaskingRule result = await dataMaskingPolicy.CreateOrUpdateDataMaskingRuleAsync(dataMaskingRuleName, dataMaskingRule);

Console.WriteLine($"Succeeded: {result}");

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
{
  "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": "Default",
    "numberFrom": null,
    "numberTo": null,
    "prefixSize": null,
    "suffixSize": null,
    "replacementString": null
  }
}
{
  "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": "Default",
    "numberFrom": null,
    "numberTo": null,
    "prefixSize": null,
    "suffixSize": null,
    "replacementString": null
  }
}
Create/Update data masking rule for numbers. Sample request
PUT 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/rule1?api-version=2023-08-01

{
  "properties": {
    "schemaName": "dbo",
    "tableName": "Table_1",
    "columnName": "test1",
    "maskingFunction": "Number",
    "numberFrom": "0",
    "numberTo": "2"
  }
}

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/2023-08-01/examples/DataMaskingRuleCreateOrUpdateNumber.json
// this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" 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";
DataMaskingPolicyName dataMaskingPolicyName = DataMaskingPolicyName.Default;
ResourceIdentifier dataMaskingPolicyResourceId = DataMaskingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, dataMaskingPolicyName);
DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId);

// invoke the operation
string dataMaskingRuleName = "rule1";
DataMaskingRule dataMaskingRule = new DataMaskingRule
{
    SchemaName = "dbo",
    TableName = "Table_1",
    ColumnName = "test1",
    MaskingFunction = DataMaskingFunction.Number,
    NumberFrom = "0",
    NumberTo = "2",
};
DataMaskingRule result = await dataMaskingPolicy.CreateOrUpdateDataMaskingRuleAsync(dataMaskingRuleName, dataMaskingRule);

Console.WriteLine($"Succeeded: {result}");

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
{
  "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
  }
}
{
  "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
  }
}
Create/Update data masking rule for text. Sample request
PUT 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/rule1?api-version=2023-08-01

{
  "properties": {
    "schemaName": "dbo",
    "tableName": "Table_1",
    "columnName": "test1",
    "maskingFunction": "Text",
    "prefixSize": "1",
    "suffixSize": "0",
    "replacementString": "asdf"
  }
}

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/2023-08-01/examples/DataMaskingRuleCreateOrUpdateText.json
// this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" 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";
DataMaskingPolicyName dataMaskingPolicyName = DataMaskingPolicyName.Default;
ResourceIdentifier dataMaskingPolicyResourceId = DataMaskingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, dataMaskingPolicyName);
DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId);

// invoke the operation
string dataMaskingRuleName = "rule1";
DataMaskingRule dataMaskingRule = new DataMaskingRule
{
    SchemaName = "dbo",
    TableName = "Table_1",
    ColumnName = "test1",
    MaskingFunction = DataMaskingFunction.Text,
    PrefixSize = "1",
    SuffixSize = "0",
    ReplacementString = "asdf",
};
DataMaskingRule result = await dataMaskingPolicy.CreateOrUpdateDataMaskingRuleAsync(dataMaskingRuleName, dataMaskingRule);

Console.WriteLine($"Succeeded: {result}");

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
{
  "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": "Text",
    "numberFrom": null,
    "numberTo": null,
    "prefixSize": "1",
    "suffixSize": "0",
    "replacementString": "asdf"
  }
}
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 policy applies.

DataMaskingRule

A database data masking rule.

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.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

DataMaskingFunction

Enumeration

The masking function that is used for the data masking rule.

Value Description Default CCN Email Number SSN Text DataMaskingPolicyName

Enumeration

The name of the database for which the data masking policy applies.

Value Description Default DataMaskingRule

Object

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.

DataMaskingRuleState

Enumeration

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.

Value Description Enabled Disabled ErrorAdditionalInfo

Object

The resource management error additional info.

Name Type Description info

object

The additional info.

type

string

The additional info type.

ErrorDetail

Object

The error detail.

Name Type Description additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Object

Error response

Name Type Description error

ErrorDetail

The error object.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4