Edit

Share via


Set-AzStorageBlobLegalHold

Enables or disables legal hold on a Storage blob.

Syntax

NamePipelineEnable (Default)

Set-AzStorageBlobLegalHold
    [-Blob] <String>
    [-Container] <String>
    [-EnableLegalHold]
    [-TagCondition <String>]
    [-Context <IStorageContext>]
    [-ServerTimeoutPerRequest <Int32>]
    [-ClientTimeoutPerRequest <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-ConcurrentTaskCount <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

BlobPipelineEnable

Set-AzStorageBlobLegalHold
    -BlobBaseClient <BlobBaseClient>
    [-EnableLegalHold]
    [-TagCondition <String>]
    [-Context <IStorageContext>]
    [-ServerTimeoutPerRequest <Int32>]
    [-ClientTimeoutPerRequest <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-ConcurrentTaskCount <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

BlobPipelineDisable

Set-AzStorageBlobLegalHold
    -BlobBaseClient <BlobBaseClient>
    [-DisableLegalHold]
    [-TagCondition <String>]
    [-Context <IStorageContext>]
    [-ServerTimeoutPerRequest <Int32>]
    [-ClientTimeoutPerRequest <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-ConcurrentTaskCount <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

NamePipelineDisable

Set-AzStorageBlobLegalHold
    [-Blob] <String>
    [-Container] <String>
    [-DisableLegalHold]
    [-TagCondition <String>]
    [-Context <IStorageContext>]
    [-ServerTimeoutPerRequest <Int32>]
    [-ClientTimeoutPerRequest <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-ConcurrentTaskCount <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Set-AzStorageBlobLegalHold cmdlet enables or disables legal hold on a Storage blob. The cmdlet only works when the blob container has already enabled immutable Storage with versioning.

Examples

$blob = Set-AzStorageBlobLegalHold -Container $containerName -Blob $blobname  -EnableLegalHold

$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.HasLegalHold
True

This command enables legal hold on a Storage blob, then show the result. The command only works when the blob container has already enabled immutable Storage with versioning.

$blob = Get-AzStorageBlob -Container $containerName -Blob $blobname | Set-AzStorageBlobLegalHold -DisableLegalHold

$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.HasLegalHold
False

This command disables legal hold on a Storage blob with pipeline, then show the result. 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

NamePipelineEnable
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NamePipelineDisable
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

BlobPipelineEnable
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
BlobPipelineDisable
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

NamePipelineEnable
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NamePipelineDisable
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

-DisableLegalHold

Disable LegalHold on the Blob.

Parameter properties

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

Parameter sets

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

-EnableLegalHold

Enable LegalHold on the Blob.

Parameter properties

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

Parameter sets

NamePipelineEnable
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
BlobPipelineEnable
Position:Named
Mandatory:True
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