Modifier

Partager via


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.

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

$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -DaysAfterCreationGreaterThan 100
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToArchive -daysAfterModificationGreaterThan 50  -DaysAfterLastTierChangeGreaterThan 40 -InputObject $action
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToCool -DaysAfterLastAccessTimeGreaterThan 30  -EnableAutoTierToHotFromCool -InputObject $action
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToHot -DaysAfterCreationGreaterThan 100 -InputObject $action
$action = Add-AzStorageAccountManagementPolicyAction -SnapshotAction Delete -daysAfterCreationGreaterThan 100 -InputObject $action
$action 

BaseBlob.TierToCool.DaysAfterModificationGreaterThan      : 
BaseBlob.TierToCool.DaysAfterLastAccessTimeGreaterThan    : 30
BaseBlob.TierToCool.DaysAfterCreationGreaterThan          : 
BaseBlob.EnableAutoTierToHotFromCool                      : True
BaseBlob.TierToArchive.DaysAfterModificationGreaterThan   : 50
BaseBlob.TierToArchive.DaysAfterLastAccessTimeGreaterThan : 
BaseBlob.TierToArchive.DaysAfterCreationGreaterThan       : 
BaseBlob.TierToArchive.DaysAfterLastTierChangeGreaterThan : 40
BaseBlob.Delete.DaysAfterModificationGreaterThan          : 
BaseBlob.Delete.DaysAfterLastAccessTimeGreaterThan        : 
BaseBlob.Delete.DaysAfterCreationGreaterThan              : 100
BaseBlob.TierToCold.DaysAfterModificationGreaterThan      : 
BaseBlob.TierToCold.DaysAfterLastAccessTimeGreaterThan    : 
BaseBlob.TierToCold.DaysAfterCreationGreaterThan          : 
BaseBlob.TierToHot.DaysAfterModificationGreaterThan       : 
BaseBlob.TierToHot.DaysAfterLastAccessTimeGreaterThan     : 
BaseBlob.TierToHot.DaysAfterCreationGreaterThan           : 100
Snapshot.TierToCool.DaysAfterCreationGreaterThan          : 
Snapshot.TierToArchive.DaysAfterCreationGreaterThan       : 
Snapshot.TierToArchive.DaysAfterLastTierChangeGreaterThan : 
Snapshot.Delete.DaysAfterCreationGreaterThan              : 100
Snapshot.TierToCold.DaysAfterCreationGreaterThan          : 
Snapshot.TierToHot.DaysAfterCreationGreaterThan           : 
Version.TierToCool.DaysAfterCreationGreaterThan           : 
Version.TierToArchive.DaysAfterCreationGreaterThan        : 
Version.TierToArchive.DaysAfterLastTierChangeGreaterThan  : 
Version.Delete.DaysAfterCreationGreaterThan               : 
Version.TierToCold.DaysAfterCreationGreaterThan           : 
Version.TierToHot.DaysAfterCreationGreaterThan            : 

$filter = New-AzStorageAccountManagementPolicyFilter
$rule = New-AzStorageAccountManagementPolicyRule -Name Test -Action $action -Filter $filter
$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 7 actions on snapshot and blob version, then add it to a management policy rule and set to a Storage account

$action = Add-AzStorageAccountManagementPolicyAction  -SnapshotAction Delete -daysAfterCreationGreaterThan 40
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -SnapshotAction TierToArchive -daysAfterCreationGreaterThan 50
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -SnapshotAction TierToCool -daysAfterCreationGreaterThan 60
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction Delete -daysAfterCreationGreaterThan 70
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction TierToArchive -daysAfterCreationGreaterThan 80
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction TierToCool -daysAfterCreationGreaterThan 90
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BlobVersionAction TierToCold -daysAfterCreationGreaterThan 100
$action

BaseBlob.TierToCool.DaysAfterModificationGreaterThan      : 
BaseBlob.TierToCool.DaysAfterLastAccessTimeGreaterThan    : 
BaseBlob.TierToCool.DaysAfterCreationGreaterThan          : 
BaseBlob.EnableAutoTierToHotFromCool                      : 
BaseBlob.TierToArchive.DaysAfterModificationGreaterThan   : 
BaseBlob.TierToArchive.DaysAfterLastAccessTimeGreaterThan : 
BaseBlob.TierToArchive.DaysAfterCreationGreaterThan       : 
BaseBlob.TierToArchive.DaysAfterLastTierChangeGreaterThan : 
BaseBlob.Delete.DaysAfterModificationGreaterThan          : 
BaseBlob.Delete.DaysAfterLastAccessTimeGreaterThan        : 
BaseBlob.Delete.DaysAfterCreationGreaterThan              : 
BaseBlob.TierToCold.DaysAfterModificationGreaterThan      : 
BaseBlob.TierToCold.DaysAfterLastAccessTimeGreaterThan    : 
BaseBlob.TierToCold.DaysAfterCreationGreaterThan          : 
BaseBlob.TierToHot.DaysAfterModificationGreaterThan       : 
BaseBlob.TierToHot.DaysAfterLastAccessTimeGreaterThan     : 
BaseBlob.TierToHot.DaysAfterCreationGreaterThan           : 
Snapshot.TierToCool.DaysAfterCreationGreaterThan          : 60
Snapshot.TierToArchive.DaysAfterCreationGreaterThan       : 50
Snapshot.TierToArchive.DaysAfterLastTierChangeGreaterThan : 
Snapshot.Delete.DaysAfterCreationGreaterThan              : 40
Snapshot.TierToCold.DaysAfterCreationGreaterThan          : 
Snapshot.TierToHot.DaysAfterCreationGreaterThan           : 
Version.TierToCool.DaysAfterCreationGreaterThan           : 90
Version.TierToArchive.DaysAfterCreationGreaterThan        : 80
Version.TierToArchive.DaysAfterLastTierChangeGreaterThan  : 
Version.Delete.DaysAfterCreationGreaterThan               : 70
Version.TierToCold.DaysAfterCreationGreaterThan           : 100
Version.TierToHot.DaysAfterCreationGreaterThan            : 

$filter = New-AzStorageAccountManagementPolicyFilter
$rule = New-AzStorageAccountManagementPolicyRule -Name Test -Action $action -Filter $filter
$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

-BaseBlobAction

The management policy action for baseblob.

Type:String
Accepted values:Delete, TierToArchive, TierToCool, TierToCold, TierToHot
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-BlobVersionAction

The management policy action for blob version.

Type:String
Accepted values:Delete, TierToArchive, TierToCool, TierToCold, TierToHot
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DaysAfterCreationGreaterThan

Integer value indicating the age in days after creation.

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

-DaysAfterLastAccessTimeGreaterThan

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
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DaysAfterLastTierChangeGreaterThan

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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DaysAfterModificationGreaterThan

Integer value indicating the age in days after last modification.

Type:Int32
Position:Named
Default value:None
Required:True
Accept pipeline input:False
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

-EnableAutoTierToHotFromCool

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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

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
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SnapshotAction

The management policy action for snapshot.

Type:String
Accepted values:Delete, TierToArchive, TierToCool, TierToCold, TierToHot
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSManagementPolicyActionGroup

Outputs

PSManagementPolicyActionGroup