Add-AzStorageAccountManagementPolicyAction
Adds an action to the input ManagementPolicy Action Group object, or creates a ManagementPolicy Action Group object with the action. The object can be used in New-AzStorageAccountManagementPolicyRule.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
Add-AzStorageAccountManagementPolicyAction
-BaseBlobAction <String>
-DaysAfterModificationGreaterThan <Int32>
[-DaysAfterLastTierChangeGreaterThan <Int32>]
[-InputObject <PSManagementPolicyActionGroup>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Add-AzStorageAccountManagementPolicyAction
-BaseBlobAction <String>
-DaysAfterLastAccessTimeGreaterThan <Int32>
[-EnableAutoTierToHotFromCool]
[-InputObject <PSManagementPolicyActionGroup>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Add-AzStorageAccountManagementPolicyAction
-BaseBlobAction <String>
-DaysAfterCreationGreaterThan <Int32>
[-InputObject <PSManagementPolicyActionGroup>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Add-AzStorageAccountManagementPolicyAction
-SnapshotAction <String>
-DaysAfterCreationGreaterThan <Int32>
[-DaysAfterLastTierChangeGreaterThan <Int32>]
[-InputObject <PSManagementPolicyActionGroup>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Add-AzStorageAccountManagementPolicyAction
-BlobVersionAction <String>
-DaysAfterCreationGreaterThan <Int32>
[-DaysAfterLastTierChangeGreaterThan <Int32>]
[-InputObject <PSManagementPolicyActionGroup>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Add-AzStorageAccountManagementPolicyAction cmdlet adds an action to the input ManagementPolicy Action Group object, or creates a ManagementPolicy Action Group object with the action.
Examples
Example 1: Creates a ManagementPolicy Action Group object with 4 actions, then add it to a management policy rule and set to a Storage account
PS C:\>$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -daysAfterModificationGreaterThan 100
PS C:\>$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToArchive -daysAfterModificationGreaterThan 50 -DaysAfterLastTierChangeGreaterThan 40 -InputObject $action
PS C:\>$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToCool -DaysAfterLastAccessTimeGreaterThan 30 -EnableAutoTierToHotFromCool -InputObject $action
PS C:\>$action = Add-AzStorageAccountManagementPolicyAction -SnapshotAction Delete -daysAfterCreationGreaterThan 100 -InputObject $action
PS C:\>$action
BaseBlob.TierToCool.DaysAfterModificationGreaterThan :
BaseBlob.TierToCool.DaysAfterLastAccessTimeGreaterThan : 30
BaseBlob.EnableAutoTierToHotFromCool : True
BaseBlob.TierToArchive.DaysAfterModificationGreaterThan : 50
BaseBlob.TierToArchive.DaysAfterLastAccessTimeGreaterThan :
BaseBlob.TierToArchive.DaysAfterLastTierChangeGreaterThan : 40
BaseBlob.Delete.DaysAfterModificationGreaterThan : 100
BaseBlob.Delete.DaysAfterLastAccessTimeGreaterThan :
Snapshot.TierToCool.DaysAfterCreationGreaterThan :
Snapshot.TierToArchive.DaysAfterCreationGreaterThan :
Snapshot.TierToArchive.DaysAfterLastTierChangeGreaterThan :
Snapshot.Delete.DaysAfterCreationGreaterThan : 100
Version.TierToCool.DaysAfterCreationGreaterThan :
Version.TierToArchive.DaysAfterCreationGreaterThan :
Version.TierToArchive.DaysAfterLastTierChangeGreaterThan :
Version.Delete.DaysAfterCreationGreaterThan :
PS C:\>$filter = New-AzStorageAccountManagementPolicyFilter
PS C:\>$rule = New-AzStorageAccountManagementPolicyRule -Name Test -Action $action -Filter $filter
PS C:\>$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -Rule $rule
The first command create a ManagementPolicy Action Group object, the following 3 commands add 3 actions to the object. Then add it to a management policy rule and set to a Storage account.
Example 2: Creates a ManagementPolicy Action Group object with 6 actions on snapshot and blob version, then add it to a management policy rule and set to a Storage account
PS C:\> $action = Add-AzStorageAccountManagementPolicyAction -SnapshotAction Delete -daysAfterCreationGreaterThan 40
PS C:\> $action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -SnapshotAction TierToArchive -daysAfterCreationGreaterThan 50
PS C:\> $action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -SnapshotAction TierToCool -daysAfterCreationGreaterThan 60
PS C:\> $action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction Delete -daysAfterCreationGreaterThan 70
PS C:\> $action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction TierToArchive -daysAfterCreationGreaterThan 80
PS C:\> $action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction TierToCool -daysAfterCreationGreaterThan 90
PS C:\> $action
BaseBlob.TierToCool.DaysAfterModificationGreaterThan :
BaseBlob.TierToCool.DaysAfterLastAccessTimeGreaterThan :
BaseBlob.TierToArchive.DaysAfterModificationGreaterThan :
BaseBlob.TierToArchive.DaysAfterLastAccessTimeGreaterThan :
BaseBlob.Delete.DaysAfterModificationGreaterThan :
BaseBlob.Delete.DaysAfterLastAccessTimeGreaterThan :
Snapshot.TierToCool.DaysAfterCreationGreaterThan : 60
Snapshot.TierToArchive.DaysAfterCreationGreaterThan : 50
Snapshot.TierToArchive.DaysAfterLastTierChangeGreaterThan :
Snapshot.Delete.DaysAfterCreationGreaterThan : 40
Version.TierToCool.DaysAfterCreationGreaterThan : 90
Version.TierToArchive.DaysAfterCreationGreaterThan : 80
Version.TierToArchive.DaysAfterLastTierChangeGreaterThan :
Version.Delete.DaysAfterCreationGreaterThan : 70
PS C:\>$filter = New-AzStorageAccountManagementPolicyFilter
PS C:\>$rule = New-AzStorageAccountManagementPolicyRule -Name Test -Action $action -Filter $filter
PS C:\>$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -Rule $rule
The first command create a ManagementPolicy Action Group object, the following 5 commands add 5 actions on snapshot and blob version to the object. Then add it to a management policy rule and set to a Storage account.
Parameters
The management policy action for baseblob.
| Type: | String |
| Accepted values: | Delete, TierToArchive, TierToCool |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The management policy action for blob version.
| Type: | String |
| Accepted values: | Delete, TierToArchive, TierToCool |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Integer value indicating the age in days after creation.
| Type: | Int32 |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Integer value indicating the age in days after last blob access. This property can only be used in conjuction with last access time tracking policy.
| Type: | Int32 |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Integer value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions. It requires daysAfterModificationGreaterThan to be set for baseBlobs based actions, or daysAfterModificationGreaterThan to be set for snapshots and blob version based actions.
| Type: | Int32 |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Integer value indicating the age in days after last modification.
| Type: | Int32 |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with Azure.
| Type: | IAzureContextContainer |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Enables auto tiering of a blob from cool to hot on a blob access. It only works with TierToCool action and DaysAfterLastAccessTimeGreaterThan.
| Type: | SwitchParameter |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
If input the ManagementPolicy Action object, will set the action to the input action object. If not input, will create a new action object.
| Type: | PSManagementPolicyActionGroup |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
The management policy action for snapshot.
| Type: | String |
| Accepted values: | Delete, TierToArchive, TierToCool |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |