Skip to content

Commit 20f6315

Browse files
committed
CLI examples
1 parent b9ef53b commit 20f6315

File tree

1 file changed

+88
-101
lines changed

1 file changed

+88
-101
lines changed

articles/storage/blobs/object-replication-configure.md

Lines changed: 88 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Configure object replication (preview)
33
titleSuffix: Azure Storage
4-
description:
4+
description: Learn how to configure object replication to asynchronously copy block blobs from a container in one storage account to another.
55
services: storage
66
author: tamram
77

@@ -24,14 +24,15 @@ This article describes how to configure object replication for your storage acco
2424

2525
Before you configure object replication, create the source and destination storage accounts if they do not already exist. Both accounts must be general-purpose v2 storage accounts. For more information, see [Create an Azure Storage account](../common/storage-account-create.md).
2626

27-
# [Azure portal](#tab/portal)
27+
Also, make sure that you have registered for the following feature previews:
2828

29-
Before you configure object replication in the Azure portal, create the source and destination containers in their respective storage accounts, if they do not already exist.
29+
- [Object replication (preview)](object-replication-overview.md)
30+
- [Blob versioning (preview)](versioning-overview.md)
31+
- [Change feed support in Azure Blob Storage (Preview)](storage-blob-change-feed.md)
3032

31-
Next, make sure you have enabled the following prerequisites:
33+
# [Azure portal](#tab/portal)
3234

33-
- [Change feed (preview)](storage-blob-change-feed.md) on the source account
34-
- [Blob versioning (preview)](versioning-overview.md) on the source and destination accounts
35+
Before you configure object replication in the Azure portal, create the source and destination containers in their respective storage accounts, if they do not already exist. Also, enabled blob versioning and change feed on the source account, and enable blob versioning on the destination account.
3536

3637
To create a replication policy in the Azure portal, follow these steps:
3738

@@ -119,12 +120,6 @@ Get-AzStorageBlobServiceProperty -ResourceGroupName $rgname `
119120
Get-AzStorageBlobServiceProperty -ResourceGroupName $rgname `
120121
-StorageAccountName $destAccountName
121122
122-
# Create new containers in the source and destination accounts.
123-
$srcAccount | New-AzStorageContainer $srcContainerName1
124-
$destAccount | New-AzStorageContainer $destContainerName1
125-
$srcAccount | New-AzStorageContainer $srcContainerName2
126-
$destAccount | New-AzStorageContainer $destContainerName2
127-
128123
# Create containers in the source and destination accounts.
129124
Get-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $srcAccountName |
130125
New-AzStorageContainer $srcContainerName1
@@ -158,124 +153,116 @@ Set-AzStorageObjectReplicationPolicy -ResourceGroupName $rgname `
158153

159154
# [Azure CLI](#tab/azure-cli)
160155

161-
To create a replication policy with Azure CLI, first install version [1.14.1-preview](https://www.powershellgallery.com/packages/Az.Storage/1.14.1-preview) of the Az.Storage PowerShell module. Follow these steps to install the preview module:
156+
To create a replication policy with Azure CLI, first install version ??? of the Azure CLI. For more information, see [Install the Azure CLI](/cli/azure/install-azure-cli).
162157

163-
Refer to [Install the Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) article to install and import the preview module supporting object replication capability.
158+
Run the following command to install the Azure Storage preview module for Azure CLI:
164159

160+
```azurecli
165161
az extension add -n storage-ors-preview
162+
```
166163

167-
To start working with Azure CLI, sign in with your Azure credentials.
164+
Next, sign in with your Azure credentials:
168165

166+
```azurecli
169167
az login
168+
```
170169

171-
Enable both Change feed and Versioning on the source storage account. Make sure you’re already registered for [Change feed](https://azure.microsoft.com/blog/change-feed-support-now-available-in-preview-for-azure-blob-storage/) and Versioning capabilities.
172-
173-
az storage blob service-properties update --enable-versioning --resource-group \<resource group\> --account-name \<source storage account\>
174-
175-
az storage blob service-properties update --enable-change-feed --resource-group \<resource group\> --account-name \<source storage account\>
176-
177-
Enable Versioning on the destination storage account.
178-
179-
az storage blob service-properties update --enable-versioning --resource-group \<resource group\> --account-name \<destination storage account\>
180-
181-
Create a new replication policy and an associated rule(s) and specify the desired prefix and replication behavior for the objects, that existed prior to configuring object replication.
182-
183-
az storage account ors-policy create \\
184-
185-
\--account-name \<destination storage account\> \\
186-
187-
\--resource-group \<resource group\> \\
188-
189-
\--source-account \<source storage account\> \\
190-
191-
\--destination-account \<destination storage account\> \\
192-
193-
\--source-container \<source container\> \\
194-
195-
\--min-creation-time '2020-02-19T16:05:00Z' \\
196-
197-
\--prefix-match prod\_
198-
199-
For list of available parameters and their values refer to Azure CLI object replication extension documentation.
200-
201-
Enable object replication on the source account by adding the replication policy to it.
202-
203-
az storage account ors-policy show -g \<resource group\> -n \<destination storage account\> --policy-id \<policy id from the previous step\> \| az storage account ors-policy create -g \<resource group\> -n \<source storage account\> -p "\@-"
204-
205-
Save the replication policy ID and the rule ID into variables for further orchestration.
206-
207-
\$policyid = (az storage account ors-policy create --account-name \<source/destination storage account\> --resource-group \<resource group\> --properties \@{path}) --query policyId)
208-
209-
\$ruleid = (az storage account ors-policy create --account-name \<source/destination storage account\> --resource-group \<resource group\> --properties \@{path}) --query rules.ruleId)
210-
211-
List replication policies in effect on a given storage account.
212-
213-
az storage account ors-policy list \\
214-
215-
\--account-name \<source/destination storage account\> \\
216-
217-
\--resource-group \<resource group\>
218-
219-
Retrieve details of a specific replication policy.
220-
221-
az storage account ors-policy show \\
222-
223-
\--policy-id \$policyid \\
224-
225-
\--account-name \<source/destination storage account\> \\
226-
227-
\--resource-group \<resource group\>
228-
229-
Change the source account name by updating the existing replication policy.
230-
231-
az storage account ors-policy update \\
232-
233-
\--policy-id \$policyid \\
170+
Enable blob versioning on the source and destination storage accounts, and enable change feed on the source account. Make sure that you have already registered for the [change feed](https://azure.microsoft.com/blog/change-feed-support-now-available-in-preview-for-azure-blob-storage/) and Versioning capabilities.
234171

235-
\--account-name \<destination storage account\> \\
172+
```azurecli
173+
az storage blob service-properties update --resource-group <resource-group> \
174+
--account-name <source-storage-account> \
175+
--enable-versioning
236176
237-
\--resource-group \<resource group\> \\
177+
az storage blob service-properties update --resource-group <resource-group> \
178+
--account-name <source-storage-account> \
179+
--enable-change-feed
238180
239-
\-s \<new source storage account\>
181+
az storage blob service-properties update --resource-group <resource-group> \
182+
--account-name <dest-storage-account> \
183+
--enable-versioning
184+
```
240185

241-
Add rule to an existing replication policy.
186+
Create the source and destination containers in their respective storage accounts.
242187

243-
az storage account ors-policy rule add \\
188+
```azurecli
189+
az storage container create --account-name <source-storage-account> --name source-container3 --auth-mode login
190+
az storage container create --account-name <source-storage-account> --name source-container4 --auth-mode login
244191
245-
\--policy-id \$policyid \\
192+
az storage container create --account-name <dest-storage-account> --name source-container3 --auth-mode login
193+
az storage container create --account-name <dest-storage-account> --name source-container4 --auth-mode login
194+
```
246195

247-
\--account-name \<destination storage account\> \\
196+
Create a new replication policy and associated rules on the destination account.
197+
198+
```azurecli
199+
az storage account or-policy create --account-name <dest-storage-account> \
200+
--resource-group <resource-group> \
201+
--source-account <source-storage-account> \
202+
--destination-account <dest-storage-account> \
203+
--source-container source-container3 \
204+
--destination-container dest-container3 \
205+
--min-creation-time '2020-05-10T00:00:00Z' \
206+
--prefix-match a
207+
208+
az storage account or-policy rule add --account-name <dest-storage-account> \
209+
--destination-container dest-container4 \
210+
--policy-id <policy-id> \
211+
--resource-group <resource-group> \
212+
--source-container source-container4 \
213+
--prefix-match b
214+
```
248215

249-
\--resource-group \<resource group\> \\
216+
Create the policy on the source account using the policy ID.
250217

251-
\--destination-container \<destination container\> \\
218+
```azurecli
219+
az storage account or-policy show --resource-group <resource-group> \
220+
--name <dest-storage-account> \
221+
--policy-id <policy-id> |
222+
--az storage account or-policy create --resource-group <resource-group> \
223+
--name <source-storage-account> \
224+
--policy "@-"
225+
```
252226

253-
\--source-container \<source container\> \\
227+
---
254228

255-
\--prefix-match test\_ \\
229+
## Remove a replication policy
256230

257-
\--min-creation-time '2020-02-19T16:05:00Z'
231+
To remove a replication policy and its associated rules, use Azure portal, PowerShell, or CLI.
258232

259-
List all rules in effect for a given replication policy.
233+
# [Azure portal](#tab/portal)
260234

261-
az storage account ors-policy rule list \\
235+
To remove a replication policy in the Azure portal, follow these steps:
262236

263-
\--policy-id \$policyid \\
237+
1. Navigate to the source storage account in the Azure portal.
238+
1. Under **Settings**, select **Object replication**.
239+
1. Click the **More** button next to the policy name.
240+
1. Select **Delete Rules**.
264241

265-
\--account-name \<source/destination storage account\> \\
242+
# [PowerShell](#tab/powershell)
266243

267-
\--resource-group \<resource group\>
244+
To remove a replication policy, delete the policy from both the source account and the destination account. Deleting the policy also deletes any rules associated with it.
268245

269-
When no longer needed, remove the replication policy from the source and
270-
destination accounts.
246+
```powershell
247+
Get-AzStorageObjectReplicationPolicy -ResourceGroupName $rgname -StorageAccountName $destAccountName | Remove-AzStorageObjectReplicationPolicy
248+
Get-AzStorageObjectReplicationPolicy -ResourceGroupName $rgname -StorageAccountName $srcAccountName | Remove-AzStorageObjectReplicationPolicy
249+
```
271250

272-
az storage account ors-policy remove \\
251+
# [Azure CLI](#tab/azure-cli)
273252

274-
\--policy-id \$policyid \\
253+
To remove a replication policy, delete the policy from both the source account and the destination account. Deleting the policy also deletes any rules associated with it.
275254

276-
\--account-name \<source/destination storage account\> \\
255+
```azurecli
256+
az storage account or-policy delete \
257+
--policy-id $policyid \
258+
--account-name <source-storage-account> \
259+
--resource-group <resource-group>
277260
278-
\--resource-group \<resource group\>
261+
az storage account or-policy delete \
262+
--policy-id $policyid \
263+
--account-name <dest-storage-account> \
264+
--resource-group <resource-group>
265+
```
279266

280267
---
281268

0 commit comments

Comments
 (0)