Edit

Share via


Restore-AzStorageContainer

Restores a previously deleted Azure storage blob container.

Syntax

Default (Default)

Restore-AzStorageContainer
    [-Name] <String>
    [-VersionId] <String>
    [-Context <IStorageContext>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Restore-AzStorageContainer cmdlet restores a previously deleted Azure storage blob container. This cmdlet only works after enabled Container softdelete with Enable-AzStorageBlobDeleteRetentionPolicy.

Examples

Example 1: List containers include deleted containers, and restore all deleted containers with pipeline

Get-AzStorageContainer -IncludeDeleted -Context $ctx | Where-Object { $_.IsDeleted } | Restore-AzStorageContainer
Storage Account Name: storageaccountname

Name                 PublicAccess         LastModified                   IsDeleted  VersionId
----                 ------------         ------------                   ---------  ---------
container1           Off
container2           Off

This command lists all containers include deleted containers, filter out all the deleted containers, then restore all deleted container to the same container name with pipeline.

Example 2: Restore a single deleted container

Get-AzStorageContainer -IncludeDeleted -Context $ctx | Where-Object { $_.IsDeleted }

   Storage Account Name: storageaccountname

Name                 PublicAccess         LastModified                   IsDeleted  VersionId
----                 ------------         ------------                   ---------  ---------
container1                                8/28/2020 10:18:13 AM +00:00   True       01D685BC91A88F22
container2                                9/4/2020 12:52:37 PM +00:00    True       01D67D248986B6DA

Restore-AzStorageContainer -Name container1 -VersionId 01D685BC91A88F22 -Context $ctx

   Storage Account Name: storageaccountname

Name                 PublicAccess         LastModified                   IsDeleted  VersionId
----                 ------------         ------------                   ---------  ---------
container1           Off

This first command lists all containers and filter out deleted containers. The secondary command restores a deleted container by manually input the parameters.

Parameters

-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

-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

-Name

The name of the previously deleted container.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:N, Container, DeletedContainerName

Parameter sets

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

-VersionId

The version of the previously deleted container.

Parameter properties

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

Parameter sets

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

String

IStorageContext

Outputs

Boolean