Edit

Share via


Set-AzStorageObjectReplicationPolicy

Creates or updates the specified object replication policy in a Storage account.

Syntax

AccountName (Default)

Set-AzStorageObjectReplicationPolicy
    [-ResourceGroupName] <String>
    [-StorageAccountName] <String>
    -SourceAccount <String>
    -Rule <PSObjectReplicationPolicyRule[]>
    [-PolicyId <String>]
    [-DestinationAccount <String>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

PolicyObject

Set-AzStorageObjectReplicationPolicy
    [-ResourceGroupName] <String>
    [-StorageAccountName] <String>
    -InputObject <PSObjectReplicationPolicy>
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

AccountObject

Set-AzStorageObjectReplicationPolicy
    -StorageAccount <PSStorageAccount>
    -SourceAccount <String>
    -Rule <PSObjectReplicationPolicyRule[]>
    [-PolicyId <String>]
    [-DestinationAccount <String>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Set-AzStorageObjectReplicationPolicy cmdlet creates or updates the specified object replication policy in a Storage account.

Examples

Example 1: Set object replication policy to both destination and source account.

$rule1 = New-AzStorageObjectReplicationPolicyRule -SourceContainer src1 -DestinationContainer dest1

$rule2 = New-AzStorageObjectReplicationPolicyRule -SourceContainer src -DestinationContainer dest -MinCreationTime 2019-01-01T16:00:00Z -PrefixMatch a,abc,dd

$srcAccount = Get-AzStorageAccount -ResourceGroupName "myresourcegroup" -AccountName "mysourceaccount"

Set-AzStorageObjectReplicationPolicy -ResourceGroupName "myresourcegroup" -AccountName "mydestaccount" -PolicyId default -SourceAccount $srcAccount.Id  -Rule $rule1,$rule2

ResourceGroupName StorageAccountName PolicyId                             EnabledTime SourceAccount   DestinationAccount Rules
----------------- ------------------ --------                             ----------- -------------   ------------------ -----
myresourcegroup   mydestaccount      56bfa11c-81ef-4f8d-b307-5e5386e16fba             mysourceaccount mydestaccount      [5fa8b1d6-4985-4abd-a0b3-ec4d07295a43,...]

$destPolicy = Get-AzStorageObjectReplicationPolicy -ResourceGroupName "myresourcegroup" -AccountName "mydestaccount"

Set-AzStorageObjectReplicationPolicy -ResourceGroupName "myresourcegroup" -AccountName "mysourceaccount" -InputObject $destPolicy

ResourceGroupName StorageAccountName PolicyId                             EnabledTime SourceAccount   DestinationAccount Rules
----------------- ------------------ --------                             ----------- -------------   ------------------ -----
myresourcegroup   mysourceaccount    56bfa11c-81ef-4f8d-b307-5e5386e16fba             mysourceaccount mydestaccount      [5fa8b1d6-4985-4abd-a0b3-ec4d07295a43,...]

This command sets object replication policy to both destination and source account. First create 2 object replication policy rules, and set policy to destination account with the 2 rules and source account resource Id. Then get the object replication policy from destination account and set to source account. Please note, when storage account has AllowCrossTenantReplication as false, SourceAccount and DestinationAccount should be account resource Id.

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

-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:AzContext, 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

-DestinationAccount

Object Replication Policy DestinationAccount, if SourceAccount is account name it should be account name, else should be account resource id. Default value will be the input StorageAccountName, or the resourceID of the account.

Parameter properties

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

Parameter sets

AccountName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
AccountObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

Object Replication Policy Object to Set to the specified Account.

Parameter properties

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

Parameter sets

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

-PolicyId

Object Replication Policy Id. It should be a GUID or 'default'. If not input the PolicyId, will use 'default', which means to create a new policy and the Id of the new policy will be returned in the created policy.

Parameter properties

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

Parameter sets

AccountName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
AccountObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Resource Group Name.

Parameter properties

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

Parameter sets

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

-Rule

Object Replication Policy Rules.

Parameter properties

Type:

PSObjectReplicationPolicyRule[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-SourceAccount

Object Replication Policy SourceAccount. It should be resource id if allowCrossTenantReplication is false..

Parameter properties

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

Parameter sets

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

-StorageAccount

Storage account object

Parameter properties

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

Parameter sets

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

-StorageAccountName

Storage Account Name.

Parameter properties

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

Parameter sets

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

PSStorageAccount

PSObjectReplicationPolicy

Outputs

PSObjectReplicationPolicy