Set-AzStorageBlobInventoryPolicy
在記憶體帳戶中建立或更新 Blob 清查原則。
語法
Set-AzStorageBlobInventoryPolicy
[-ResourceGroupName] <String>
[-StorageAccountName] <String>
-Rule <PSBlobInventoryPolicyRule[]>
[-Disabled]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzStorageBlobInventoryPolicy
[-ResourceGroupName] <String>
[-StorageAccountName] <String>
-Policy <PSBlobInventoryPolicy>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzStorageBlobInventoryPolicy
-StorageAccount <PSStorageAccount>
-Rule <PSBlobInventoryPolicyRule[]>
[-Disabled]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzStorageBlobInventoryPolicy
-StorageAccount <PSStorageAccount>
-Policy <PSBlobInventoryPolicy>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzStorageBlobInventoryPolicy
[-StorageAccountResourceId] <String>
-Rule <PSBlobInventoryPolicyRule[]>
[-Disabled]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzStorageBlobInventoryPolicy
[-StorageAccountResourceId] <String>
-Policy <PSBlobInventoryPolicy>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Set-AzStorageBlobInventoryPolicy Cmdlet 會在記憶體帳戶中建立或更新 Blob 清查原則。
範例
範例 1:使用 BlobInventoryPolicy 規則物件建立或更新 Blob 清查原則。
$rule1 = New-AzStorageBlobInventoryPolicyRule -Name Test1 -Destination $containerName -Disabled -Format Csv -Schedule Daily -ContainerSchemaField Name,Metadata,PublicAccess,Last-mOdified,LeaseStatus,LeaseState,LeaseDuration,HasImmutabilityPolicy,HasLegalHold -PrefixMatch con1,con2
$rule2 = New-AzStorageBlobInventoryPolicyRule -Name Test2 -Destination $containerName -Format Parquet -Schedule Weekly -IncludeBlobVersion -IncludeSnapshot -BlobType blockBlob,appendBlob -PrefixMatch aaa,bbb `
-BlobSchemaField name,Creation-Time,Last-Modified,Content-Length,Content-MD5,BlobType,AccessTier,AccessTierChangeTime,Expiry-Time,hdi_isfolder,Owner,Group,Permissions,Acl,Metadata
$rule3 = New-AzStorageBlobInventoryPolicyRule -Name Test3 -Destination $containerName -Format Parquet -Schedule Weekly -IncludeBlobVersion -IncludeSnapshot -IncludeDeleted -BlobType blockBlob,appendBlob -PrefixMatch aaa,bbb `
-ExcludePrefix ccc,ddd -BlobSchemaField name,Last-Modified,BlobType,AccessTier,AccessTierChangeTime,Content-Type,Content-CRC64,CopyId,x-ms-blob-sequence-number,TagCount
$policy = Set-AzStorageBlobInventoryPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -Disabled -Rule $rule1,$rule2,$rule3
$policy
StorageAccountName : mystorageaccount
ResourceGroupName : myresourcegroup
Name : DefaultInventoryPolicy
Id : /subscriptions/{subscription-Id}/resourceGroups/myresourcegroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount/inventoryPolicies/default
Type : Microsoft.Storage/storageAccounts/inventoryPolicies
LastModifiedTime : 5/12/2021 8:53:38 AM
Enabled : False
Rules : {Test1, Test2, Test3}
$policy.Rules
Name Enabled Destination ObjectType Format Schedule IncludeSnapshots IncludeBlobVersions IncludeDeleted BlobTypes PrefixMatch ExcludePrefix SchemaFields
---- ------- ----------- ---------- ------ -------- ---------------- ------------------- -------------- --------- ----------- ------------- ------------
Test1 False containername Container Csv Daily {con1, con2} {Name, Metadata, PublicAccess, Last-Modified...}
Test2 True containername Blob Parquet Weekly True True {blockBlob, appendBlob} {aaa, bbb} {Name, Creation-Time, Last-Modified, Content-Length...}
Test3 True containername Blob Parquet Weekly True True True {blockBlob, appendBlob} {aaa, bbb} {ccc, ddd} {Name, Content-Type, Content-CRC64, Last-Modified...}
前 2 個命令會建立 3 個 BlobInventoryPolicy 規則對象:規則 “Test1” for contaienr inventory;Blob 清查的規則 「Test2」 和 「Test3」。 下列命令會將 Blob 清查原則設定為具有 2 個規則物件的記憶體帳戶,然後顯示更新的原則和規則屬性。
範例 2:使用 Json 格式原則建立或更新記憶體帳戶的 Blob 清查原則。
$policy = Set-AzStorageBlobInventoryPolicy -ResourceGroupName $resourceGroupName -StorageAccountName $accountName -Policy (@{
Enabled=$true;
Rules=(@{
Enabled=$true;
Name="Test1";
Destination=$containerName;
Definition=(@{
ObjectType="Blob";
Format="Csv";
Schedule="Weekly";
SchemaFields=@("name","Content-Length","BlobType","Snapshot","VersionId","IsCurrentVersion");
Filters=(@{
BlobTypes=@("blockBlob","appendBlob");
PrefixMatch=@("prefix1","prefix2");
IncludeSnapshots=$true;
IncludeBlobVersions=$true;
})
})
},
@{
Enabled=$false;
Name="Test2";
Destination=$containerName;
Definition=(@{
ObjectType="Container";
Format="Parquet";
Schedule="Daily";
SchemaFields=@("name","Metadata","PublicAccess","DefaultEncryptionScope","DenyEncryptionScopeOverride");
Filters=(@{
PrefixMatch=@("conpre1","conpre2");
})
})
},
@{
Enabled=$false;
Name="Test3";
Destination=$containerName;
Definition=(@{
ObjectType="Blob";
Format="Csv";
Schedule="Weekly";
SchemaFields=@("name","Deleted","RemainingRetentionDays","Content-Type","Content-Language","Cache-Control","Content-Disposition");
Filters=(@{
BlobTypes=@("blockBlob","appendBlob");
PrefixMatch=@("conpre1","conpre2");
ExcludePrefix=@("expre1","expre2");
IncludeDeleted=$true
})
})
})
})
$policy
StorageAccountName : weiadlscanary1
ResourceGroupName : weitry
Name : DefaultInventoryPolicy
Id : /subscriptions/{subscription-Id}/resourceGroups/weitry/providers/Microsoft.Storage/storageAccounts/weiadlscanary1/inventoryPolicies/default
Type : Microsoft.Storage/storageAccounts/inventoryPolicies
LastModifiedTime : 5/12/2021 9:02:21 AM
Enabled : True
Rules : {Test1, Test2, Test3}
$policy.Rules
Name Enabled Destination ObjectType Format Schedule IncludeSnapshots IncludeBlobVersions IncludeDeleted BlobTypes PrefixMatch ExcludePrefix SchemaFields
---- ------- ----------- ---------- ------ -------- ---------------- ------------------- -------------- --------- ----------- ------------- ------------
Test1 True containername Blob Csv Weekly True True {blockBlob, appendBlob} {prefix1, prefix2} {Name, Content-Length, BlobType, Snapshot...}
Test2 False containername Container Parquet Daily {conpre1, conpre2} {Name, Metadata, PublicAccess}
Test3 False containername Blob Csv Weekly True {blockBlob, appendBlob} {conpre1, conpre2} {expre1, expre2} {Name, Content-Type, Content-Cache, Content-Language...} {name, Metadata, PublicAccess}
此命令會使用 json 格式原則建立或更新記憶體帳戶的 Blob 清查原則。
範例 3:從記憶體帳戶取得 Blob 清查原則,然後將它設定為另一個記憶體帳戶。
$policy = Get-AzStorageBlobInventoryPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" | Set-AzStorageBlobInventoryPolicy -ResourceGroupName "myresourcegroup2" -AccountName "mystorageaccount2"
此命令會先從記憶體帳戶取得 Blob 清查原則,然後將它設定為另一個記憶體帳戶。 Proeprties:目的地、啟用和原則規則將會設定為目的地帳戶。
範例 4:從記憶體帳戶取得 Blob 清查原則規則,然後將它設定為另一個記憶體帳戶。
$policy = ,((Get-AzStorageBlobInventoryPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount").Rules) | Set-AzStorageBlobInventoryPolicy -ResourceGroupName "myresourcegroup2" -AccountName "mystorageaccount2" -Disabled
此命令會先從記憶體帳戶取得 Blob 清查原則,然後將它的規則設定為另一個記憶體帳戶。
參數
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
類型: | SwitchParameter |
別名: | cf |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-DefaultProfile
用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。
類型: | IAzureContextContainer |
別名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Disabled
Blob 清查原則預設為啟用,請指定此參數來停用它。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Policy
要設定的 Blob 清查原則物件
類型: | PSBlobInventoryPolicy |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ResourceGroupName
資源組名。
類型: | String |
Position: | 0 |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-Rule
Blob 清查原則規則。 使用 New-AzStorageBlobInventoryPolicyRule Cmdlet 取得 物件。
類型: | PSBlobInventoryPolicyRule[] |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-StorageAccount
記憶體帳戶物件
類型: | PSStorageAccount |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-StorageAccountName
儲存體帳戶名稱。
類型: | String |
別名: | AccountName |
Position: | 1 |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-StorageAccountResourceId
記憶體帳戶資源標識碼。
類型: | String |
Position: | 0 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。
類型: | SwitchParameter |
別名: | wi |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
輸入
Microsoft.Azure.Commands.Management.Storage.Models.PSBlobInventoryPolicySchema