Redigera

Dela via


New-AzSqlDatabaseDataMaskingRule

Creates a data masking rule for a database.

Syntax

New-AzSqlDatabaseDataMaskingRule
   -MaskingFunction <String>
   [-PrefixSize <UInt32>]
   [-ReplacementString <String>]
   [-SuffixSize <UInt32>]
   [-NumberFrom <Double>]
   [-NumberTo <Double>]
   [-PassThru]
   -SchemaName <String>
   -TableName <String>
   -ColumnName <String>
   [-ServerName] <String>
   [-DatabaseName] <String>
   [-ResourceGroupName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The New-AzSqlDatabaseDataMaskingRule cmdlet creates a data masking rule for an Azure SQL database. To use the cmdlet, use the ResourceGroupName, ServerName, and DatabaseName parameters to identify the rule. Provide the TableName and ColumnName to specify the target of the rule and the MaskingFunction parameter to define how the data is masked. If MaskingFunction has a value of Number or Text, you can specify the NumberFrom and NumberTo parameters, for number masking, or the PrefixSize, ReplacementString, and SuffixSize for text masking. If the command succeeds and the PassThru parameter is used, the cmdlet returns an object describing the data masking rule properties in addition to the rule identifiers. Rule identifiers include, but are not limited to, ResourceGroupName, ServerName, DatabaseName, and RuleID. This cmdlet is also supported by the SQL Server Stretch Database service on Azure.

Examples

Example 1: Create a data masking rule for a number column in a database

New-AzSqlDatabaseDataMaskingRule -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"  -SchemaName "Schema01" -TableName "Table01" -ColumnName "Column01" -MaskingFunction "Number" -NumberFrom 5 -NumberTo 14

This command creates a data masking rule for the column named Column01 in the table named Table01 in the schema named Schema01. The database named Database01 contains all these items. The rule is a number masking rule that uses a random number between 5 and 14 as the mask value.

Parameters

-ColumnName

Specifies the name of the column targeted by the masking rule.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatabaseName

Specifies the name of the database.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaskingFunction

Specifies the masking function that the rule uses. The acceptable values for this parameter are:

  • Default
  • NoMasking
  • Text
  • Number
  • SocialSecurityNumber
  • CreditCardNumber
  • Email The default value is Default.
Type:String
Accepted values:NoMasking, Default, Text, Number, SocialSecurityNumber, CreditCardNumber, Email
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NumberFrom

Specifies the lower bound number of the interval from which a random value is selected. Specify this parameter only if you specify a value of Number for the MaskingFunction parameter. The default value is 0.

Type:Nullable<T>[Double]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-NumberTo

Specifies the upper bound number of the interval from which a random value is selected. Specify this parameter only if you specify a value of Number for the MaskingFunction parameter. The default value is 0.

Type:Nullable<T>[Double]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PrefixSize

Specifies the number of characters at the start of the text that are not masked. Specify this parameter only if you specify a value of Text for the MaskingFunction parameter. The default value is 0.

Type:Nullable<T>[UInt32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ReplacementString

Specifies the number of characters in the end of the text that are not masked. Specify this parameter only if you specify a value of Text for the MaskingFunction parameter. The default value is an empty string.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

Specifies the name of the resource group to which the database is assigned.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SchemaName

Specifies the name of a schema.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ServerName

Specifies the name of the server that hosts the database.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SuffixSize

Specifies the number of characters at the end of the text that are not masked. Specify this parameter only if you specify a value of Text for the MaskingFunction parameter. The default value is 0.

Type:Nullable<T>[UInt32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-TableName

Specifies the name of the database table that contains the masked column.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Nullable<T>[[System.UInt32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]

Nullable<T>[[System.Double, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]

Outputs

DatabaseDataMaskingRuleModel