編輯

共用方式為


Enable-AzStorageBlobRestorePolicy

Enables Blob Restore Policy on a Storage account.

Syntax

Enable-AzStorageBlobRestorePolicy
      [-ResourceGroupName] <String>
      [-StorageAccountName] <String>
      -RestoreDays <Int32>
      [-PassThru]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Enable-AzStorageBlobRestorePolicy
      -StorageAccount <PSStorageAccount>
      -RestoreDays <Int32>
      [-PassThru]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Enable-AzStorageBlobRestorePolicy
      [-ResourceId] <String>
      -RestoreDays <Int32>
      [-PassThru]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

The Enable-AzStorageBlobRestorePolicy cmdlet enables Blob Restore Policy for the Azure Storage Blob service.

Examples

Example 1: Enables Blob Restore Policy for the Azure Storage Blob service on a Storage account

Enable-AzStorageBlobDeleteRetentionPolicy -ResourceGroupName "myresourcegoup" -StorageAccountName "mystorageaccount" -RetentionDays 5

Update-AzStorageBlobServiceProperty -ResourceGroupName "myresourcegoup" -StorageAccountName "mystorageaccount" -EnableChangeFeed $true

StorageAccountName            : mystorageaccount
ResourceGroupName             : myresourcegoup
DefaultServiceVersion         : 
DeleteRetentionPolicy.Enabled : True
DeleteRetentionPolicy.Days    : 5
RestorePolicy.Enabled         : False
RestorePolicy.Days            : 
RestorePolicy.MinRestoreTime  : 
ChangeFeed                    : True
IsVersioningEnabled           : True

Enable-AzStorageBlobRestorePolicy -ResourceGroupName "myresourcegoup" -StorageAccountName "mystorageaccount" -RestoreDays 4

Get-AzStorageBlobServiceProperty -ResourceGroupName "myresourcegoup" -StorageAccountName "mystorageaccount"

StorageAccountName            : mystorageaccount
ResourceGroupName             : myresourcegoup
DefaultServiceVersion         : 
DeleteRetentionPolicy.Enabled : True
DeleteRetentionPolicy.Days    : 5
RestorePolicy.Enabled         : True
RestorePolicy.Days            : 4
RestorePolicy.MinRestoreTime  : 8/28/2020 6:00:59 AM
ChangeFeed                    : True
IsVersioningEnabled           : True

This command first enable Blob softdelete and changefeed, then enables Blob Restore Policy, finally check the setting in Blob service properties. The Blob service RestorePolicy.Days must be smaller than DeleteRetentionPolicy.Days. Blob softdelete and ChangeFeed must be enabled before enable blob Restore Policy. If softdelete and Changefeed are just enabled, might need wait for some time for server to handle the setting, before enable Blob restore policy.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PassThru

Display ServiceProperties

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Resource Group Name.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceId

Input a Storage account Resource Id, or a Blob service properties Resource Id.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-RestoreDays

Sets the number of days for the blob can be restored..

Type:Int32
Aliases:Days
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-StorageAccount

Storage account object

Type:PSStorageAccount
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-StorageAccountName

Storage Account Name.

Type:String
Aliases:AccountName, Name
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSStorageAccount

String

Outputs

PSRestorePolicy