你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
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>]
说明
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”用于 contaienr 清单;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 清单策略,然后将其设置为另一个存储帐户。 代理:目标、已启用和策略规则将设置为目标帐户。
示例 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
存储帐户资源 ID。
类型: | 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