New-AzStorageAccountManagementPolicyRule
Membuat objek aturan ManagementPolicy, yang dapat digunakan dalam Set-AzStorageAccountManagementPolicy.
Sintaks
New-AzStorageAccountManagementPolicyRule
[-Name] <String>
[-Disabled]
-Action <PSManagementPolicyActionGroup>
[-Filter <PSManagementPolicyRuleFilter>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Deskripsi
Cmdlet New-AzStorageAccountManagementPolicyRule membuat objek aturan ManagementPolicy, yang dapat digunakan di Set-AzStorageAccountManagementPolicy.
Contoh
Contoh 1: Membuat objek aturan ManagementPolicy, lalu mengatur ke Akun Penyimpanan
$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
Perintah ini membuat objek aturan ManagementPolicy, dengan objek grup tindakan ManagementPolicy berisi 4 tindakan, objek filter aturan ManagementPolicy, lalu atur aturan ke Akun Penyimpanan.
Parameter
-Action
Objek yang menentukan kumpulan tindakan. Dapatkan Objek dengan cmdlet Add-AzureStorageAccountManagementPolicyAction
Jenis: | PSManagementPolicyActionGroup |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-DefaultProfile
Kredensial, akun, penyewa, dan langganan yang digunakan untuk komunikasi dengan Azure.
Jenis: | IAzureContextContainer |
Alias: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | False |
Terima karakter wildcard: | False |
-Disabled
Aturan dinonaktifkan jika diatur.
Jenis: | SwitchParameter |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | False |
Terima karakter wildcard: | False |
-Filter
Objek yang menentukan set filter. Dapatkan Objek dengan cmdlet New-AzureStorageAccountManagementPolicyFilter
Jenis: | PSManagementPolicyRuleFilter |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-Name
Nama aturan dapat berisi kombinasi karakter alfa numerik apa pun. Nama aturannya peka huruf besar/kecil. Itu harus unik dalam sebuah kebijakan.
Jenis: | String |
Position: | 0 |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | False |
Terima karakter wildcard: | False |
Input
None
Output
Azure PowerShell