Edit

Share via


New-AzStorageBlobInventoryPolicyRule

Creates a blob inventory policy rule object, which can be used in Set-AzStorageBlobInventoryPolicy.

Syntax

BlobRuleParameterSet (Default)

New-AzStorageBlobInventoryPolicyRule
    [-Name] <String>
    -Destination <String>
    -Format <String>
    -Schedule <String>
    -BlobSchemaField <String[]>
    -BlobType <String[]>
    [-Disabled]
    [-PrefixMatch <String[]>]
    [-ExcludePrefix <String[]>]
    [-IncludeSnapshot]
    [-IncludeBlobVersion]
    [-IncludeDeleted]
    [-CreationTimeLastNDay <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ContainerRuleParameterSet

New-AzStorageBlobInventoryPolicyRule
    [-Name] <String>
    -Destination <String>
    -Format <String>
    -Schedule <String>
    -ContainerSchemaField <String[]>
    [-Disabled]
    [-PrefixMatch <String[]>]
    [-ExcludePrefix <String[]>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The New-AzStorageBlobInventoryPolicyRule cmdlet creates a blob inventory policy rule object, which can be used in Set-AzStorageBlobInventoryPolicy.

Examples

Example 1: Create blob inventory policy rule objects, then sets blob inventory policy with the rule objects.

$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  -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 -CreationTimeLastNDay 30
$rule3 = New-AzStorageBlobInventoryPolicyRule -Name Test3 -Destination $containerName -Format Parquet -Schedule Weekly  -IncludeSnapshot -IncludeDeleted -BlobType blockBlob,appendBlob -PrefixMatch aaa,bbb `
                 -ExcludePrefix ccc,ddd -BlobSchemaField name,Last-Modified,BlobType,AccessTier,AccessTierChangeTime,Content-Type,Content-CRC64,CopyId,DeletionId,Deleted,DeletedTime,RemainingRetentionDays

$policy = Set-AzStorageBlobInventoryPolicy -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -Disabled -Rule $rule1,$rule2

$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                                            CreationTime
----  ------- -----------   ---------- ------  -------- ---------------- ------------------- -------------- ---------               -----------  ------------- ------------                                            ------------
Test1 False   containername Container  Csv     Daily                                                                                {con1, con2}               {Name, Metadata, PublicAccess, Last-Modified...}
Test2 True    containername Blob       Parquet Weekly   True                                                {blockBlob, appendBlob} {aaa, bbb}                 {Name, Creation-Time, Last-Modified, Content-Length...} LastNDays=30
Test3 True    containername Blob       Parquet Weekly   True                                 True           {blockBlob, appendBlob} {aaa, bbb}   {ccc, ddd}    {Name, Last-Modified, BlobType, AccessTier...}

This first 3 commands create 3 BlobInventoryPolicy rule objects: rule "Test1" for container inventory; rule "Test2" for blob inventory; rule "Test3" for blob inventory with more schema fields, excludePrefix specified, and IncludeDeleted enabled. The following command sets blob inventory policy to a Storage account with the 3 rule objects, then show the updated policy and rules properties.

Parameters

-BlobSchemaField

Specifies the fields and properties of the Blob object to be included in the inventory. Valid values include: Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Metadata, LastAccessTime, AccessTierInferred, Tags. 'Name' is a required schemafield. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only for HierarchicalNamespace enabled accounts.'Tags' field is only valid for non HierarchicalNamespace accounts. If specify '-IncludeSnapshot', will include 'Snapshot' in the inventory. If specify '-IncludeBlobVersion', will include 'VersionId, 'IsCurrentVersion' in the inventory.

Parameter properties

Type:

String[]

Default value:None
Accepted values:Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Metadata, LastAccessTime, AccessTierInferred, Tags, Etag, Content-Type, Content-Encoding, Content-Language, Content-CRC64, Cache-Control, Content-Disposition, LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, x-ms-blob-sequence-number, EncryptionScope, IncrementalCopy, DeletionId, DeletedTime, TagCount
Supports wildcards:False
DontShow:False

Parameter sets

BlobRuleParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-BlobType

Sets the blob types for the blob inventory policy rule. Valid values include blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs.

Parameter properties

Type:

String[]

Default value:None
Accepted values:blockBlob, pageBlob, appendBlob
Supports wildcards:False
DontShow:False

Parameter sets

BlobRuleParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ContainerSchemaField

Specifies the fields and properties of the container object to be included in the inventory. Valid values include: Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold. 'Name' is a required schemafield.

Parameter properties

Type:

String[]

Default value:None
Accepted values:Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays
Supports wildcards:False
DontShow:False

Parameter sets

ContainerRuleParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-CreationTimeLastNDay

Filter the objects which has creation time in last N days. The valid value is between 1 to 36500. Inventory schema 'Creation-Time' is mandatory with this filter.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BlobRuleParameterSet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Destination

The container name where blob inventory files are stored. Must be pre-created.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Disabled

The rule is disabled if set it.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ExcludePrefix

Sets an array of strings with maximum 10 blob prefixes to be excluded from the inventory.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Format

Specifies the format for the inventory files. Possible values include: 'Csv', 'Parquet'

Parameter properties

Type:String
Default value:None
Accepted values:Csv, Parquet
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IncludeBlobVersion

The rule is disabled if set it.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BlobRuleParameterSet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IncludeDeleted

Includes deleted blob in blob inventory. When include delete blob, for ContainerSchemaFields, must include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For BlobSchemaFields, on HNS enabled storage accounts, must include 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays', and on Hns disabled accounts must include 'Deleted and RemainingRetentionDays', else they must be excluded.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BlobRuleParameterSet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IncludeSnapshot

The rule is disabled if set it.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BlobRuleParameterSet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PrefixMatch

Sets an array of strings for blob prefixes to be matched..

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Schedule

This field is used to schedule an inventory formation. Possible values include: 'Daily', 'Weekly'

Parameter properties

Type:String
Default value:None
Accepted values:Daily, Weekly
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

PSBlobInventoryPolicyRule