Blob Inventory Policies - Create Or Update
Sets the blob inventory policy to the specified storage account.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/default?api-version=2022-09-01
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
account
|
path | True |
string |
The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. |
blob
|
path | True |
The name of the storage account blob inventory policy. It should always be 'default' |
|
resource
|
path | True |
string |
The name of the resource group within the user's subscription. The name is case insensitive. Regex pattern: |
subscription
|
path | True |
string |
The ID of the target subscription. |
api-version
|
query | True |
string |
The API version to use for this operation. |
Request Body
Name | Required | Type | Description |
---|---|---|---|
properties.policy | True |
The storage account blob inventory policy object. It is composed of policy rules. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
OK -- Put blob inventory policy successfully. |
|
Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | impersonate your user account |
Examples
Storage |
Storage |
Storage |
StorageAccountSetBlobInventoryPolicy
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/inventoryPolicies/default?api-version=2022-09-01
{
"properties": {
"policy": {
"enabled": true,
"type": "Inventory",
"rules": [
{
"enabled": true,
"name": "inventoryPolicyRule1",
"destination": "container1",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob",
"pageBlob"
],
"prefixMatch": [
"inventoryprefix1",
"inventoryprefix2"
],
"excludePrefix": [
"excludeprefix1",
"excludeprefix2"
],
"includeSnapshots": true,
"includeBlobVersions": true
},
"format": "Csv",
"schedule": "Daily",
"objectType": "Blob",
"schemaFields": [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"Metadata"
]
}
},
{
"enabled": true,
"name": "inventoryPolicyRule2",
"definition": {
"format": "Parquet",
"schedule": "Weekly",
"objectType": "Container",
"schemaFields": [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold"
]
},
"destination": "container2"
}
]
}
}
}
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/inventoryPolicies/default",
"name": "DefaultInventoryPolicy",
"type": "Microsoft.Storage/storageAccounts/inventoryPolicies",
"properties": {
"policy": {
"enabled": true,
"type": "Inventory",
"rules": [
{
"enabled": true,
"name": "inventoryPolicyRule1",
"destination": "container1",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob",
"pageBlob"
],
"prefixMatch": [
"inventoryprefix1",
"inventoryprefix2"
],
"excludePrefix": [
"excludeprefix1",
"excludeprefix2"
],
"includeSnapshots": true,
"includeBlobVersions": true
},
"format": "Csv",
"schedule": "Daily",
"objectType": "Blob",
"schemaFields": [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"Metadata"
]
}
},
{
"enabled": true,
"name": "inventoryPolicyRule2",
"definition": {
"format": "Parquet",
"schedule": "Weekly",
"objectType": "Container",
"schemaFields": [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold"
]
},
"destination": "container2"
}
]
},
"lastModifiedTime": "2020-10-05T02:53:39.0932539Z"
}
}
StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForHnsAccount
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/inventoryPolicies/default?api-version=2022-09-01
{
"properties": {
"policy": {
"enabled": true,
"type": "Inventory",
"rules": [
{
"enabled": true,
"name": "inventoryPolicyRule1",
"destination": "container1",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob",
"pageBlob"
],
"prefixMatch": [
"inventoryprefix1",
"inventoryprefix2"
],
"excludePrefix": [
"excludeprefix1",
"excludeprefix2"
],
"includeSnapshots": true,
"includeBlobVersions": true,
"includeDeleted": true
},
"format": "Csv",
"schedule": "Daily",
"objectType": "Blob",
"schemaFields": [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"ContentType",
"ContentEncoding",
"ContentLanguage",
"ContentCRC64",
"CacheControl",
"Metadata",
"DeletionId",
"Deleted",
"DeletedTime",
"RemainingRetentionDays"
]
}
},
{
"enabled": true,
"name": "inventoryPolicyRule2",
"definition": {
"format": "Parquet",
"schedule": "Weekly",
"objectType": "Container",
"schemaFields": [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold",
"Etag",
"DefaultEncryptionScope",
"DenyEncryptionScopeOverride",
"ImmutableStorageWithVersioningEnabled",
"Deleted",
"Version",
"DeletedTime",
"RemainingRetentionDays"
]
},
"destination": "container2"
}
]
}
}
}
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/inventoryPolicies/default",
"name": "DefaultInventoryPolicy",
"type": "Microsoft.Storage/storageAccounts/inventoryPolicies",
"properties": {
"policy": {
"enabled": true,
"type": "Inventory",
"rules": [
{
"enabled": true,
"name": "inventoryPolicyRule1",
"destination": "container1",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob",
"pageBlob"
],
"prefixMatch": [
"inventoryprefix1",
"inventoryprefix2"
],
"excludePrefix": [
"excludeprefix1",
"excludeprefix2"
],
"includeSnapshots": true,
"includeBlobVersions": true,
"includeDeleted": true
},
"format": "Csv",
"schedule": "Daily",
"objectType": "Blob",
"schemaFields": [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"ContentType",
"ContentEncoding",
"ContentLanguage",
"ContentCRC64",
"CacheControl",
"Metadata",
"DeletionId",
"Deleted",
"DeletedTime",
"RemainingRetentionDays"
]
}
},
{
"enabled": true,
"name": "inventoryPolicyRule2",
"definition": {
"format": "Parquet",
"schedule": "Weekly",
"objectType": "Container",
"schemaFields": [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold",
"Etag",
"DefaultEncryptionScope",
"DenyEncryptionScopeOverride",
"ImmutableStorageWithVersioningEnabled",
"Deleted",
"Version",
"DeletedTime",
"RemainingRetentionDays"
]
},
"destination": "container2"
}
]
}
}
}
StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForNonHnsAccount
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/inventoryPolicies/default?api-version=2022-09-01
{
"properties": {
"policy": {
"enabled": true,
"type": "Inventory",
"rules": [
{
"enabled": true,
"name": "inventoryPolicyRule1",
"destination": "container1",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob",
"pageBlob"
],
"prefixMatch": [
"inventoryprefix1",
"inventoryprefix2"
],
"excludePrefix": [
"excludeprefix1",
"excludeprefix2"
],
"includeSnapshots": true,
"includeBlobVersions": true,
"includeDeleted": true
},
"format": "Csv",
"schedule": "Daily",
"objectType": "Blob",
"schemaFields": [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"Tags",
"ContentType",
"ContentEncoding",
"ContentLanguage",
"ContentCRC64",
"CacheControl",
"Metadata",
"Deleted",
"RemainingRetentionDays"
]
}
},
{
"enabled": true,
"name": "inventoryPolicyRule2",
"definition": {
"format": "Parquet",
"schedule": "Weekly",
"objectType": "Container",
"schemaFields": [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold",
"Etag",
"DefaultEncryptionScope",
"DenyEncryptionScopeOverride",
"ImmutableStorageWithVersioningEnabled",
"Deleted",
"Version",
"DeletedTime",
"RemainingRetentionDays"
]
},
"destination": "container2"
}
]
}
}
}
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/inventoryPolicies/default",
"name": "DefaultInventoryPolicy",
"type": "Microsoft.Storage/storageAccounts/inventoryPolicies",
"properties": {
"policy": {
"enabled": true,
"type": "Inventory",
"rules": [
{
"enabled": true,
"name": "inventoryPolicyRule1",
"destination": "container1",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob",
"pageBlob"
],
"prefixMatch": [
"inventoryprefix1",
"inventoryprefix2"
],
"excludePrefix": [
"excludeprefix1",
"excludeprefix2"
],
"includeSnapshots": true,
"includeBlobVersions": true,
"includeDeleted": true
},
"format": "Csv",
"schedule": "Daily",
"objectType": "Blob",
"schemaFields": [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"Tags",
"ContentType",
"ContentEncoding",
"ContentLanguage",
"ContentCRC64",
"CacheControl",
"Metadata",
"Deleted",
"RemainingRetentionDays"
]
}
},
{
"enabled": true,
"name": "inventoryPolicyRule2",
"definition": {
"format": "Parquet",
"schedule": "Weekly",
"objectType": "Container",
"schemaFields": [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold",
"Etag",
"DefaultEncryptionScope",
"DenyEncryptionScopeOverride",
"ImmutableStorageWithVersioningEnabled",
"Deleted",
"Version",
"DeletedTime",
"RemainingRetentionDays"
]
},
"destination": "container2"
}
]
}
}
}
Definitions
Name | Description |
---|---|
Blob |
The storage account blob inventory policy. |
Blob |
An object that defines the blob inventory rule. |
Blob |
An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. |
Blob |
The name of the storage account blob inventory policy. It should always be 'default' |
Blob |
An object that wraps the blob inventory rule. Each rule is uniquely defined by name. |
Blob |
The storage account blob inventory policy rules. |
Cloud |
An error response from the Storage service. |
Cloud |
An error response from the Storage service. |
created |
The type of identity that created the resource. |
format |
This is a required field, it specifies the format for the inventory files. |
Inventory |
The valid value is Inventory |
object |
This is a required field. This field specifies the scope of the inventory created either at the blob or container level. |
schedule |
This is a required field. This field is used to schedule an inventory formation. |
system |
Metadata pertaining to creation and last modification of the resource. |
BlobInventoryPolicy
The storage account blob inventory policy.
Name | Type | Description |
---|---|---|
id |
string |
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
name |
string |
The name of the resource |
properties.lastModifiedTime |
string |
Returns the last modified date and time of the blob inventory policy. |
properties.policy |
The storage account blob inventory policy object. It is composed of policy rules. |
|
systemData |
Metadata pertaining to creation and last modification of the resource. |
|
type |
string |
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
BlobInventoryPolicyDefinition
An object that defines the blob inventory rule.
Name | Type | Description |
---|---|---|
filters |
An object that defines the filter set. |
|
format |
This is a required field, it specifies the format for the inventory files. |
|
objectType |
This is a required field. This field specifies the scope of the inventory created either at the blob or container level. |
|
schedule |
This is a required field. This field is used to schedule an inventory formation. |
|
schemaFields |
string[] |
This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is always required. The valid values for this field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field values 'Tags, TagCount' are only valid for Non-Hns accounts. |
BlobInventoryPolicyFilter
An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional.
Name | Type | Description |
---|---|---|
blobTypes |
string[] |
An array of predefined enum values. Valid values include blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when definition.objectType property is set to 'Blob'. |
excludePrefix |
string[] |
An array of strings with maximum 10 blob prefixes to be excluded from the inventory. |
includeBlobVersions |
boolean |
Includes blob versions in blob inventory when value is set to true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this property is set to true, else they must be excluded. |
includeDeleted |
boolean |
For 'Container' definition.objectType the definition.schemaFields must include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' definition.objectType and HNS enabled storage accounts the definition.schemaFields must include 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be excluded. |
includeSnapshots |
boolean |
Includes blob snapshots in blob inventory when value is set to true. The definition.schemaFields value 'Snapshot' is required if this property is set to true, else it must be excluded. |
prefixMatch |
string[] |
An array of strings with maximum 10 blob prefixes to be included in the inventory. |
BlobInventoryPolicyName
The name of the storage account blob inventory policy. It should always be 'default'
Name | Type | Description |
---|---|---|
default |
string |
BlobInventoryPolicyRule
An object that wraps the blob inventory rule. Each rule is uniquely defined by name.
Name | Type | Description |
---|---|---|
definition |
An object that defines the blob inventory policy rule. |
|
destination |
string |
Container name where blob inventory files are stored. Must be pre-created. |
enabled |
boolean |
Rule is enabled when set to true. |
name |
string |
A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. |
BlobInventoryPolicySchema
The storage account blob inventory policy rules.
Name | Type | Description |
---|---|---|
destination |
string |
Deprecated Property from API version 2021-04-01 onwards, the required destination container name must be specified at the rule level 'policy.rule.destination' |
enabled |
boolean |
Policy is enabled if set to true. |
rules |
The storage account blob inventory policy rules. The rule is applied when it is enabled. |
|
type |
The valid value is Inventory |
CloudError
An error response from the Storage service.
Name | Type | Description |
---|---|---|
error |
An error response from the Storage service. |
CloudErrorBody
An error response from the Storage service.
Name | Type | Description |
---|---|---|
code |
string |
An identifier for the error. Codes are invariant and are intended to be consumed programmatically. |
details |
A list of additional details about the error. |
|
message |
string |
A message describing the error, intended to be suitable for display in a user interface. |
target |
string |
The target of the particular error. For example, the name of the property in error. |
createdByType
The type of identity that created the resource.
Name | Type | Description |
---|---|---|
Application |
string |
|
Key |
string |
|
ManagedIdentity |
string |
|
User |
string |
format
This is a required field, it specifies the format for the inventory files.
Name | Type | Description |
---|---|---|
Csv |
string |
|
Parquet |
string |
InventoryRuleType
The valid value is Inventory
Name | Type | Description |
---|---|---|
Inventory |
string |
objectType
This is a required field. This field specifies the scope of the inventory created either at the blob or container level.
Name | Type | Description |
---|---|---|
Blob |
string |
|
Container |
string |
schedule
This is a required field. This field is used to schedule an inventory formation.
Name | Type | Description |
---|---|---|
Daily |
string |
|
Weekly |
string |
systemData
Metadata pertaining to creation and last modification of the resource.
Name | Type | Description |
---|---|---|
createdAt |
string |
The timestamp of resource creation (UTC). |
createdBy |
string |
The identity that created the resource. |
createdByType |
The type of identity that created the resource. |
|
lastModifiedAt |
string |
The timestamp of resource last modification (UTC) |
lastModifiedBy |
string |
The identity that last modified the resource. |
lastModifiedByType |
The type of identity that last modified the resource. |