共用方式為


Add-AzStorageAccountManagementPolicyAction

將動作新增至輸入ManagementPolicy 動作群組物件,或使用動作建立ManagementPolicy動作群組物件。 對象可用於 New-AzStorageAccountManagementPolicyRule。

語法

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

Add-AzStorageAccountManagementPolicyAction Cmdlet 會將動作新增至輸入 ManagementPolicy Action Group 物件,或使用動作建立 ManagementPolicy Action Group 物件。

範例

範例 1:建立具有 4 個動作的 ManagementPolicy 動作群組物件,然後將它新增至管理原則規則,並設定為記憶體帳戶

$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

第一個命令會建立ManagementPolicy 動作群組物件,下列3個命令會將3個動作新增至物件。 然後將它新增至管理原則規則,並將 它設定為記憶體帳戶。

範例 2:在快照集和 Blob 版本上建立具有 7 個動作的 ManagementPolicy 動作群組對象,然後將它新增至管理原則規則,並設定為記憶體帳戶

$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

第一個命令會建立ManagementPolicy 動作群組物件,下列5個命令會將快照集和 Blob 版本的5個動作新增至物件。 然後將它新增至管理原則規則,並將 它設定為記憶體帳戶。

參數

-BaseBlobAction

baseblob 的管理原則動作。

類型:String
接受的值:Delete, TierToArchive, TierToCool, TierToCold, TierToHot
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-BlobVersionAction

Blob 版本的管理原則動作。

類型:String
接受的值:Delete, TierToArchive, TierToCool, TierToCold, TierToHot
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-DaysAfterCreationGreaterThan

整數值,表示建立后的天數。

類型:Int32
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-DaysAfterLastAccessTimeGreaterThan

整數值,表示最後一次 Blob 存取後的天數。 此屬性只能用於與上次存取時間追蹤原則的結合。

類型:Int32
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-DaysAfterLastTierChangeGreaterThan

整數值,指出最後一個 Blob 層變更時間後的天數。 此屬性僅適用於 tierToArchive 動作。 它需要針對baseBlobs型動作設定 daysAfterModificationGreaterThan,或針對快照集和 Blob 版本型動作設定 daysAfterModificationGreaterThan。

類型:Int32
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DaysAfterModificationGreaterThan

整數值,指出上次修改後的天數。

類型:Int32
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。

類型:IAzureContextContainer
別名:AzContext, AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-EnableAutoTierToHotFromCool

啟用 Blob 從非經常性存取到經常性存取 Blob 的自動階層處理。 它只適用於 TierToCool 巨集指令和 DaysAfterLastAccessTimeGreaterThan。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-InputObject

如果輸入ManagementPolicy Action物件,則會將動作設定為輸入動作物件。 如果沒有輸入,將會建立新的動作物件。

類型:PSManagementPolicyActionGroup
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-SnapshotAction

快照集的管理原則動作。

類型:String
接受的值:Delete, TierToArchive, TierToCool, TierToCold, TierToHot
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

輸入

PSManagementPolicyActionGroup

輸出

PSManagementPolicyActionGroup