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>
   [-InputObject <PSManagementPolicyActionGroup>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Add-AzStorageAccountManagementPolicyAction
   -SnapshotAction <String>
   -DaysAfterCreationGreaterThan <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  -InputObject $action
PS C:\>$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction TierToCool -daysAfterModificationGreaterThan 30 -InputObject $action
PS C:\>$action = Add-AzStorageAccountManagementPolicyAction -SnapshotAction Delete -daysAfterCreationGreaterThan 100 -InputObject $action
PS C:\>$action 

BaseBlob.TierToCool.DaysAfterModificationGreaterThan    : 30
BaseBlob.TierToArchive.DaysAfterModificationGreaterThan : 50
BaseBlob.Delete.DaysAfterModificationGreaterThan        : 100
Snapshot.Delete.DaysAfterCreationGreaterThan            : 100

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.

Parameters

-BaseBlobAction

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
-DaysAfterCreationGreaterThan

Integer value indicating the age in days after creation.

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

The credentials, account, tenant, and subscription used for communication with Azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
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:Microsoft.Azure.Commands.Management.Storage.Models.PSManagementPolicyActionGroup
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-SnapshotAction

The management policy action for snapshot.

Type:String
Accepted values:Delete
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.Azure.Commands.Management.Storage.Models.PSManagementPolicyActionGroup

Outputs

Microsoft.Azure.Commands.Management.Storage.Models.PSManagementPolicyActionGroup