Edit

Share via


Set-AzStorageBlobImmutabilityPolicy

Creates or updates ImmutabilityPolicy of a Storage blob.

Syntax

NamePipeline (Default)

Set-AzStorageBlobImmutabilityPolicy
    [-Blob] <String>
    [-Container] <String>
    -ExpiresOn <DateTimeOffset>
    [-PolicyMode <String>]
    [-TagCondition <String>]
    [-Context <IStorageContext>]
    [-ServerTimeoutPerRequest <Int32>]
    [-ClientTimeoutPerRequest <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-ConcurrentTaskCount <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

BlobPipeline

Set-AzStorageBlobImmutabilityPolicy
    -BlobBaseClient <BlobBaseClient>
    -ExpiresOn <DateTimeOffset>
    [-PolicyMode <String>]
    [-TagCondition <String>]
    [-Context <IStorageContext>]
    [-ServerTimeoutPerRequest <Int32>]
    [-ClientTimeoutPerRequest <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-ConcurrentTaskCount <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Set-AzStorageBlobImmutabilityPolicy cmdlet creates or updates ImmutabilityPolicy of a Storage blob. The cmdlet only works when the blob container has already enabled immutable Storage with versioning.

Examples

Example 1: Create or update immutability policy of a Storage blob.

$blob = Set-AzStorageBlobImmutabilityPolicy -Container $containerName -Blob $blobname  -ExpiresOn (Get-Date).AddDays(100) -PolicyMode Unlocked

$blob

   AccountName: mystorageaccount, ContainerName: mycontainer

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------
testblob             BlockBlob 10485760        application/octet-stream       2021-07-19 08:56:00Z Hot                                     False      2021-07-19T08:56:01.8120788Z *

$blob.BlobProperties.ImmutabilityPolicy

ExpiresOn                    PolicyMode
---------                    ----------
10/27/2021 8:56:32 AM +00:00   Unlocked

This command creates or updates ImmutabilityPolicy of a Storage blob, then show the blob and its ImmutabilityPolicy. The command only works when the blob container has already enabled immutable Storage with versioning.

Parameters

-Blob

Blob name

Parameter properties

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

Parameter sets

NamePipeline
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-BlobBaseClient

BlobBaseClient Object

Parameter properties

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

Parameter sets

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

-ClientTimeoutPerRequest

The client side maximum execution time for each request in seconds.

Parameter properties

Type:

Nullable<T>[Int32]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:ClientTimeoutPerRequestInSeconds

Parameter sets

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

-ConcurrentTaskCount

The total amount of concurrent async tasks. The default value is 10.

Parameter properties

Type:

Nullable<T>[Int32]

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

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

Parameter sets

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

-Container

Container name

Parameter properties

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

Parameter sets

NamePipeline
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Context

Azure Storage Context Object

Parameter properties

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

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:True
Value from pipeline by property name:True
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: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

-ExpiresOn

Blob ImmutabilityPolicy ExpiresOn

Parameter properties

Type:

Nullable<T>[DateTimeOffset]

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

-PolicyMode

Blob ImmutabilityPolicy PolicyMode

Parameter properties

Type:String
Default value:None
Accepted values:Unlocked, Locked, Mutable
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

-ServerTimeoutPerRequest

The server time out for each request in seconds.

Parameter properties

Type:

Nullable<T>[Int32]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:ServerTimeoutPerRequestInSeconds

Parameter sets

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

-TagCondition

Optional Tag expression statement to check match condition. The blob request will fail when the blob tags does not match the given expression.See details in https://learn.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations#tags-conditional-operations.

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

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

Parameter sets

(All)
Position:Named
Mandatory:False
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

BlobBaseClient

IStorageContext

Outputs

AzureStorageBlob