Veritabanı veri maskeleme kuralı oluşturur veya günceller.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/Default/rules/{dataMaskingRuleName}?api-version=2025-01-01
URI Parametreleri
| Name |
İçinde |
Gerekli |
Tür |
Description |
|
databaseName
|
path |
True
|
string
|
Veritabanının adı.
|
|
dataMaskingPolicyName
|
path |
True
|
DataMaskingPolicyName
|
Veri maskeleme politikasının uygulandığı veritabanının adı.
|
|
dataMaskingRuleName
|
path |
True
|
string
|
Veri maskeleme kuralının adı.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Kaynak grubunun adı. İsim büyük/küçük harfe duyarsızdır.
|
|
serverName
|
path |
True
|
string
|
Sunucunun adı.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
Hedef aboneliğin kimliği. Değer bir UUID olmalıdır.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Bu işlem için kullanılacak API sürümü.
|
İstek Gövdesi
| Name |
Gerekli |
Tür |
Description |
|
properties.columnName
|
True
|
string
|
Veri maskeleme kuralının uygulandığı sütun adı.
|
|
properties.maskingFunction
|
True
|
DataMaskingFunction
|
Veri maskeleme kuralı için kullanılan maskeleme işlevi.
|
|
properties.schemaName
|
True
|
string
|
Veri maskeleme kuralının uygulandığı şema adı.
|
|
properties.tableName
|
True
|
string
|
Veri maskeleme kuralının uygulandığı tablo adı.
|
|
properties.aliasName
|
|
string
|
Diğer ad. Bu eski bir parametredir ve artık kullanılmaz.
|
|
properties.numberFrom
|
|
string
|
Maskeleme kuralının numberFrom özelliği. maskingFunction Number olarak ayarlandıysa gereklidir, aksi takdirde bu parametre yoksayılır.
|
|
properties.numberTo
|
|
string
|
Veri maskeleme kuralının numberTo özelliği. maskingFunction Number olarak ayarlandıysa gereklidir, aksi takdirde bu parametre yoksayılır.
|
|
properties.prefixSize
|
|
string
|
maskingFunction Metin olarak ayarlandıysa, dizenin başında maskesi kaldırılmış olarak gösterilecek karakter sayısı. Aksi takdirde, bu parametre yoksayılır.
|
|
properties.replacementString
|
|
string
|
maskingFunction Text olarak ayarlandıysa, dizenin kullanıma sunulmamış bölümünü maskelemede kullanılacak karakter. Aksi takdirde, bu parametre yoksayılır.
|
|
properties.ruleState
|
|
DataMaskingRuleState
|
Kural durumu. Bir kuralı silmek için kullanılır. Varolan bir kuralı silmek için schemaName, tableName, columnName, maskingFunction ve ruleState'i devre dışı olarak belirtin. Ancak, kural henüz yoksa ruleState değeri ne olursa olsun ruleState etkin olarak ayarlanmış şekilde oluşturulur.
|
|
properties.suffixSize
|
|
string
|
maskingFunction Metin olarak ayarlandıysa, dizenin sonunda maskesi kaldırılmış olarak gösterilecek karakter sayısı. Aksi takdirde, bu parametre yoksayılır.
|
Yanıtlar
| Name |
Tür |
Description |
|
200 OK
|
DataMaskingRule
|
Azure işlemi başarıyla tamamlandı.
|
|
201 Created
|
DataMaskingRule
|
Kaynak 'DataMaskingRule' oluşturma işlemi başarılı oldu
|
|
Other Status Codes
|
ErrorResponse
|
Beklenmeyen bir hata yanıtı.
|
Güvenlik
azure_auth
Azure Active Directory OAuth2 Akışı.
Tür:
oauth2
Akış:
implicit
Yetkilendirme URL’si:
https://login.microsoftonline.com/common/oauth2/authorize
Kapsamlar
| Name |
Description |
|
user_impersonation
|
kullanıcı hesabınızın kimliğine bürünme
|
Örnekler
Create/Update data masking rule for default max.
Örnek isteği
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=2025-01-01
{
"properties": {
"aliasName": "nickname",
"columnName": "test1",
"maskingFunction": "Default",
"ruleState": "Enabled",
"schemaName": "dbo",
"tableName": "Table_1"
}
}
import com.azure.resourcemanager.sql.fluent.models.DataMaskingRuleInner;
import com.azure.resourcemanager.sql.models.DataMaskingFunction;
import com.azure.resourcemanager.sql.models.DataMaskingPolicyName;
import com.azure.resourcemanager.sql.models.DataMaskingRuleState;
/**
* Samples for DataMaskingRules CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateDefaultMax.json
*/
/**
* Sample code: Create/Update data masking rule for default max.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createUpdateDataMaskingRuleForDefaultMax(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDataMaskingRules().createOrUpdateWithResponse("sqlcrudtest-6852", "sqlcrudtest-2080",
"sqlcrudtest-331", DataMaskingPolicyName.DEFAULT, "rule1",
new DataMaskingRuleInner().withRuleState(DataMaskingRuleState.ENABLED).withSchemaName("dbo")
.withTableName("Table_1").withColumnName("test1").withAliasName("nickname")
.withMaskingFunction(DataMaskingFunction.DEFAULT),
com.azure.core.util.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_create_or_update_default_max.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="SUBSCRIPTION_ID",
)
response = client.data_masking_rules.create_or_update(
resource_group_name="sqlcrudtest-6852",
server_name="sqlcrudtest-2080",
database_name="sqlcrudtest-331",
data_masking_rule_name="rule1",
parameters={
"properties": {
"aliasName": "nickname",
"columnName": "test1",
"maskingFunction": "Default",
"ruleState": "Enabled",
"schemaName": "dbo",
"tableName": "Table_1",
}
},
)
print(response)
# x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateDefaultMax.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or updates a database data masking rule.
*
* @summary creates or updates a database data masking rule.
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateDefaultMax.json
*/
async function createOrUpdateDataMaskingRuleForDefaultMax() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.dataMaskingRules.createOrUpdate(
"sqlcrudtest-6852",
"sqlcrudtest-2080",
"sqlcrudtest-331",
"rule1",
{
aliasName: "nickname",
columnName: "test1",
maskingFunction: "Default",
ruleState: "Enabled",
schemaName: "dbo",
tableName: "Table_1",
},
);
console.log(result);
}
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/SQL/stable/2025-01-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
Örnek yanıt
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": "nickname",
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Default",
"numberFrom": null,
"numberTo": null,
"prefixSize": null,
"replacementString": null,
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": null,
"tableName": "Table_1"
}
}
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": "nickname",
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Default",
"numberFrom": null,
"numberTo": null,
"prefixSize": null,
"replacementString": null,
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": null,
"tableName": "Table_1"
}
}
Create/Update data masking rule for default min.
Örnek isteği
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=2025-01-01
{
"properties": {
"columnName": "test1",
"maskingFunction": "Default",
"schemaName": "dbo",
"tableName": "Table_1"
}
}
import com.azure.resourcemanager.sql.fluent.models.DataMaskingRuleInner;
import com.azure.resourcemanager.sql.models.DataMaskingFunction;
import com.azure.resourcemanager.sql.models.DataMaskingPolicyName;
/**
* Samples for DataMaskingRules CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateDefaultMin.json
*/
/**
* Sample code: Create/Update data masking rule for default min.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createUpdateDataMaskingRuleForDefaultMin(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDataMaskingRules().createOrUpdateWithResponse("sqlcrudtest-6852", "sqlcrudtest-2080",
"sqlcrudtest-331", DataMaskingPolicyName.DEFAULT, "rule1", new DataMaskingRuleInner().withSchemaName("dbo")
.withTableName("Table_1").withColumnName("test1").withMaskingFunction(DataMaskingFunction.DEFAULT),
com.azure.core.util.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_create_or_update_default_min.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="SUBSCRIPTION_ID",
)
response = client.data_masking_rules.create_or_update(
resource_group_name="sqlcrudtest-6852",
server_name="sqlcrudtest-2080",
database_name="sqlcrudtest-331",
data_masking_rule_name="rule1",
parameters={
"properties": {
"columnName": "test1",
"maskingFunction": "Default",
"schemaName": "dbo",
"tableName": "Table_1",
}
},
)
print(response)
# x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateDefaultMin.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or updates a database data masking rule.
*
* @summary creates or updates a database data masking rule.
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateDefaultMin.json
*/
async function createOrUpdateDataMaskingRuleForDefaultMin() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.dataMaskingRules.createOrUpdate(
"sqlcrudtest-6852",
"sqlcrudtest-2080",
"sqlcrudtest-331",
"rule1",
{ columnName: "test1", maskingFunction: "Default", schemaName: "dbo", tableName: "Table_1" },
);
console.log(result);
}
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/SQL/stable/2025-01-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
Örnek yanıt
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": null,
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Default",
"numberFrom": null,
"numberTo": null,
"prefixSize": null,
"replacementString": null,
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": null,
"tableName": "Table_1"
}
}
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": null,
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Default",
"numberFrom": null,
"numberTo": null,
"prefixSize": null,
"replacementString": null,
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": null,
"tableName": "Table_1"
}
}
Create/Update data masking rule for numbers.
Örnek isteği
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=2025-01-01
{
"properties": {
"columnName": "test1",
"maskingFunction": "Number",
"numberFrom": "0",
"numberTo": "2",
"schemaName": "dbo",
"tableName": "Table_1"
}
}
import com.azure.resourcemanager.sql.fluent.models.DataMaskingRuleInner;
import com.azure.resourcemanager.sql.models.DataMaskingFunction;
import com.azure.resourcemanager.sql.models.DataMaskingPolicyName;
/**
* Samples for DataMaskingRules CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateNumber.json
*/
/**
* Sample code: Create/Update data masking rule for numbers.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createUpdateDataMaskingRuleForNumbers(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDataMaskingRules().createOrUpdateWithResponse("sqlcrudtest-6852", "sqlcrudtest-2080",
"sqlcrudtest-331", DataMaskingPolicyName.DEFAULT, "rule1",
new DataMaskingRuleInner().withSchemaName("dbo").withTableName("Table_1").withColumnName("test1")
.withMaskingFunction(DataMaskingFunction.NUMBER).withNumberFrom("0").withNumberTo("2"),
com.azure.core.util.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_create_or_update_number.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="SUBSCRIPTION_ID",
)
response = client.data_masking_rules.create_or_update(
resource_group_name="sqlcrudtest-6852",
server_name="sqlcrudtest-2080",
database_name="sqlcrudtest-331",
data_masking_rule_name="rule1",
parameters={
"properties": {
"columnName": "test1",
"maskingFunction": "Number",
"numberFrom": "0",
"numberTo": "2",
"schemaName": "dbo",
"tableName": "Table_1",
}
},
)
print(response)
# x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateNumber.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or updates a database data masking rule.
*
* @summary creates or updates a database data masking rule.
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateNumber.json
*/
async function createOrUpdateDataMaskingRuleForNumbers() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.dataMaskingRules.createOrUpdate(
"sqlcrudtest-6852",
"sqlcrudtest-2080",
"sqlcrudtest-331",
"rule1",
{
columnName: "test1",
maskingFunction: "Number",
numberFrom: "0",
numberTo: "2",
schemaName: "dbo",
tableName: "Table_1",
},
);
console.log(result);
}
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/SQL/stable/2025-01-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
Örnek yanıt
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": null,
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Number",
"numberFrom": "0",
"numberTo": "2",
"prefixSize": null,
"replacementString": null,
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": null,
"tableName": "Table_1"
}
}
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": null,
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Number",
"numberFrom": "0",
"numberTo": "2",
"prefixSize": null,
"replacementString": null,
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": null,
"tableName": "Table_1"
}
}
Create/Update data masking rule for text.
Örnek isteği
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=2025-01-01
{
"properties": {
"columnName": "test1",
"maskingFunction": "Text",
"prefixSize": "1",
"replacementString": "asdf",
"schemaName": "dbo",
"suffixSize": "0",
"tableName": "Table_1"
}
}
import com.azure.resourcemanager.sql.fluent.models.DataMaskingRuleInner;
import com.azure.resourcemanager.sql.models.DataMaskingFunction;
import com.azure.resourcemanager.sql.models.DataMaskingPolicyName;
/**
* Samples for DataMaskingRules CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateText.json
*/
/**
* Sample code: Create/Update data masking rule for text.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createUpdateDataMaskingRuleForText(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDataMaskingRules().createOrUpdateWithResponse("sqlcrudtest-6852", "sqlcrudtest-2080",
"sqlcrudtest-331", DataMaskingPolicyName.DEFAULT, "rule1",
new DataMaskingRuleInner().withSchemaName("dbo").withTableName("Table_1").withColumnName("test1")
.withMaskingFunction(DataMaskingFunction.TEXT).withPrefixSize("1").withSuffixSize("0")
.withReplacementString("asdf"),
com.azure.core.util.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_create_or_update_text.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="SUBSCRIPTION_ID",
)
response = client.data_masking_rules.create_or_update(
resource_group_name="sqlcrudtest-6852",
server_name="sqlcrudtest-2080",
database_name="sqlcrudtest-331",
data_masking_rule_name="rule1",
parameters={
"properties": {
"columnName": "test1",
"maskingFunction": "Text",
"prefixSize": "1",
"replacementString": "asdf",
"schemaName": "dbo",
"suffixSize": "0",
"tableName": "Table_1",
}
},
)
print(response)
# x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateText.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or updates a database data masking rule.
*
* @summary creates or updates a database data masking rule.
* x-ms-original-file: 2025-01-01/DataMaskingRuleCreateOrUpdateText.json
*/
async function createOrUpdateDataMaskingRuleForText() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.dataMaskingRules.createOrUpdate(
"sqlcrudtest-6852",
"sqlcrudtest-2080",
"sqlcrudtest-331",
"rule1",
{
columnName: "test1",
maskingFunction: "Text",
prefixSize: "1",
replacementString: "asdf",
schemaName: "dbo",
suffixSize: "0",
tableName: "Table_1",
},
);
console.log(result);
}
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/SQL/stable/2025-01-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
Örnek yanıt
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": null,
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Text",
"numberFrom": null,
"numberTo": null,
"prefixSize": "1",
"replacementString": "asdf",
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": "0",
"tableName": "Table_1"
}
}
{
"name": null,
"type": "Microsoft.Sql/servers/databases/dataMaskingPolicies/rules",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/rule1",
"kind": null,
"location": "Central US",
"properties": {
"aliasName": null,
"columnName": "test1",
"id": "dbo_Table_1_test1",
"maskingFunction": "Text",
"numberFrom": null,
"numberTo": null,
"prefixSize": "1",
"replacementString": "asdf",
"ruleState": "Enabled",
"schemaName": "dbo",
"suffixSize": "0",
"tableName": "Table_1"
}
}
Tanımlar
| Name |
Description |
|
createdByType
|
Kaynağı oluşturan kimliğin türü.
|
|
DataMaskingFunction
|
Veri maskeleme kuralı için kullanılan maskeleme işlevi.
|
|
DataMaskingPolicyName
|
Veri maskeleme politikasının uygulandığı veritabanının adı.
|
|
DataMaskingRule
|
Bir veritabanı veri maskeleme kuralı.
|
|
DataMaskingRuleState
|
Kural durumu. Bir kuralı silmek için kullanılır. Varolan bir kuralı silmek için schemaName, tableName, columnName, maskingFunction ve ruleState'i devre dışı olarak belirtin. Ancak, kural henüz yoksa ruleState değeri ne olursa olsun ruleState etkin olarak ayarlanmış şekilde oluşturulur.
|
|
ErrorAdditionalInfo
|
Kaynak yönetimi hatası ek bilgileri.
|
|
ErrorDetail
|
Hata ayrıntısı.
|
|
ErrorResponse
|
Hata yanıtı
|
|
systemData
|
Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.
|
createdByType
Numaralandırma
Kaynağı oluşturan kimliğin türü.
| Değer |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DataMaskingFunction
Numaralandırma
Veri maskeleme kuralı için kullanılan maskeleme işlevi.
| Değer |
Description |
|
Default
|
Varsayılan
|
|
CCN
|
CCN
|
|
Email
|
E-posta
|
|
Number
|
Sayı
|
|
SSN
|
Sosyal Güvenlik Numarası
|
|
Text
|
Metin
|
DataMaskingPolicyName
Numaralandırma
Veri maskeleme politikasının uygulandığı veritabanının adı.
| Değer |
Description |
|
Default
|
Varsayılan
|
DataMaskingRule
Nesne
Bir veritabanı veri maskeleme kuralı.
| Name |
Tür |
Description |
|
id
|
string
(arm-id)
|
Kaynağın tam kaynak kimliği. Örneğin "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
kind
|
string
|
Böyle bir Veri Maskeleme Kuralı. Metadata, Azure portal için kullanılır.
|
|
location
|
string
|
Veri maskeleme kuralının konumu.
|
|
name
|
string
|
Kaynağın adı
|
|
properties.aliasName
|
string
|
Diğer ad. Bu eski bir parametredir ve artık kullanılmaz.
|
|
properties.columnName
|
string
|
Veri maskeleme kuralının uygulandığı sütun adı.
|
|
properties.id
|
string
|
Kural Id.
|
|
properties.maskingFunction
|
DataMaskingFunction
|
Veri maskeleme kuralı için kullanılan maskeleme işlevi.
|
|
properties.numberFrom
|
string
|
Maskeleme kuralının numberFrom özelliği. maskingFunction Number olarak ayarlandıysa gereklidir, aksi takdirde bu parametre yoksayılır.
|
|
properties.numberTo
|
string
|
Veri maskeleme kuralının numberTo özelliği. maskingFunction Number olarak ayarlandıysa gereklidir, aksi takdirde bu parametre yoksayılır.
|
|
properties.prefixSize
|
string
|
maskingFunction Metin olarak ayarlandıysa, dizenin başında maskesi kaldırılmış olarak gösterilecek karakter sayısı. Aksi takdirde, bu parametre yoksayılır.
|
|
properties.replacementString
|
string
|
maskingFunction Text olarak ayarlandıysa, dizenin kullanıma sunulmamış bölümünü maskelemede kullanılacak karakter. Aksi takdirde, bu parametre yoksayılır.
|
|
properties.ruleState
|
DataMaskingRuleState
|
Kural durumu. Bir kuralı silmek için kullanılır. Varolan bir kuralı silmek için schemaName, tableName, columnName, maskingFunction ve ruleState'i devre dışı olarak belirtin. Ancak, kural henüz yoksa ruleState değeri ne olursa olsun ruleState etkin olarak ayarlanmış şekilde oluşturulur.
|
|
properties.schemaName
|
string
|
Veri maskeleme kuralının uygulandığı şema adı.
|
|
properties.suffixSize
|
string
|
maskingFunction Metin olarak ayarlandıysa, dizenin sonunda maskesi kaldırılmış olarak gösterilecek karakter sayısı. Aksi takdirde, bu parametre yoksayılır.
|
|
properties.tableName
|
string
|
Veri maskeleme kuralının uygulandığı tablo adı.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata içeren createdBy ve modifiedBy bilgileri.
|
|
type
|
string
|
Kaynağın türü. Örneğin "Microsoft. Compute/virtualMachines" veya "Microsoft. Depo/Depolama Hesapları"
|
DataMaskingRuleState
Numaralandırma
Kural durumu. Bir kuralı silmek için kullanılır. Varolan bir kuralı silmek için schemaName, tableName, columnName, maskingFunction ve ruleState'i devre dışı olarak belirtin. Ancak, kural henüz yoksa ruleState değeri ne olursa olsun ruleState etkin olarak ayarlanmış şekilde oluşturulur.
| Değer |
Description |
|
Enabled
|
Enabled
|
|
Disabled
|
Disabled
|
ErrorAdditionalInfo
Nesne
Kaynak yönetimi hatası ek bilgileri.
| Name |
Tür |
Description |
|
info
|
object
|
Ek bilgiler.
|
|
type
|
string
|
Ek bilgi türü.
|
ErrorDetail
Nesne
Hata ayrıntısı.
| Name |
Tür |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Hata ek bilgileri.
|
|
code
|
string
|
Hata kodu.
|
|
details
|
ErrorDetail[]
|
Hata ayrıntıları.
|
|
message
|
string
|
Hata iletisi.
|
|
target
|
string
|
Hata hedefi
|
ErrorResponse
Nesne
Hata yanıtı
systemData
Nesne
Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.
| Name |
Tür |
Description |
|
createdAt
|
string
(date-time)
|
Kaynak oluşturma (UTC) zaman damgası.
|
|
createdBy
|
string
|
Kaynağı oluşturan kimlik.
|
|
createdByType
|
createdByType
|
Kaynağı oluşturan kimliğin türü.
|
|
lastModifiedAt
|
string
(date-time)
|
Kaynağın son değişikliğinin zaman damgası (UTC)
|
|
lastModifiedBy
|
string
|
Kaynağı en son değiştiren kimlik.
|
|
lastModifiedByType
|
createdByType
|
Kaynağı en son değiştiren kimlik türü.
|