New-AzStorageAccountManagementPolicyRule
Creates a ManagementPolicy rule object, which can be used in Set-AzStorageAccountManagementPolicy.
Syntax
Default (Default)
New-AzStorageAccountManagementPolicyRule
[-Name] <String>
[-Disabled]
-Action <PSManagementPolicyActionGroup>
[-Filter <PSManagementPolicyRuleFilter>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The New-AzStorageAccountManagementPolicyRule cmdlet creates a ManagementPolicy rule object, which can be used in Set-AzStorageAccountManagementPolicy.
Examples
Example 1: Creates a ManagementPolicy rule object, then set to a Storage Account
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -daysAfterModificationGreaterThan 100
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToArchive -daysAfterModificationGreaterThan 50 -InputObject $action
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToCool -daysAfterModificationGreaterThan 30 -InputObject $action
$action = Add-AzStorageAccountManagementPolicyAction -SnapshotAction Delete -daysAfterCreationGreaterThan 100 -InputObject $action
$filter = New-AzStorageAccountManagementPolicyFilter -PrefixMatch blobprefix1,blobprefix2
$rule = New-AzStorageAccountManagementPolicyRule -Name rule1 -Action $action -Filter $filter
$rule
Enabled : True
Name : rule1
Definition : {
"Actions": {
"BaseBlob": {
"TierToCool": {
"DaysAfterModificationGreaterThan": 30
},
"TierToArchive": {
"DaysAfterModificationGreaterThan": 50
},
"Delete": {
"DaysAfterModificationGreaterThan": 100
}
},
"Snapshot": {
"Delete": {
"DaysAfterCreationGreaterThan": 100
}
}
},
"Filters": {
"PrefixMatch": [
"blobprefix1",
"blobprefix2"
],
"BlobTypes": [
"blockBlob"
]
}
}
$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -Rule $rule
This command create a ManagementPolicy rule object, with a ManagementPolicy action group object contains 4 actions, a ManagementPolicy rule filter object, then set the rule to a Storage Account.
Parameters
-Action
An object that defines the action set.
Get the Object with cmdlet Add-AzureStorageAccountManagementPolicyAction
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Disabled
The rule is disabled if set it.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Filter
An object that defines the filter set.
Get the Object with cmdlet New-AzureStorageAccountManagementPolicyFilter
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-Name
A rule name can contain any combination of alpha numeric characters.
Rule name is case-sensitive.
It must be unique within a policy.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
None
Outputs