0

I am writing a script to set up object replication between my Aaure storage containers. I have over 50 containers in a storage account. First I created a replication policy with below command,

first_container=$(head -1 container_list.txt)
az storage account or-policy create \
    --account-name $DESTINATION_STORAGE_ACCOUNT \
    --resource-group $DESTINATION_RESOURCE_GROUP \
    --source-account $SOURCE_STORAGE_ACCOUNT \
    --destination-account $DESTINATION_STORAGE_ACCOUNT \
    --source-container $first_container  \
    --destination-container $first_container  \
    --min-creation-time '2010-09-01T00:00:00Z'

then have a logic to add rules to the policy

policy_id=$(az storage account or-policy list --account-name $DESTINATION_STORAGE_ACCOUNT --query "[].policyId" -o tsv)
for container in $(sed -n '1!p' list.txt); do
     az storage account or-policy rule add \
         --account-name $DESTINATION_STORAGE_ACCOUNT \
         --resource-group $SOURCE_RESOURCE_GROUP \
         --source-container $container  \
         --destination-container $container  \
         --policy-id $policy_id
done

But only 10 rules are allowed in a policy, once the loop reaches to 11th container, az command will fail with the error (MaxLimitReachedForRequestParameters) Max limit has been reached for request parameters: Policy.Rules. my question is, how can I create a second replication policy through az cli ? If i execute az storage account or-policy create command again, instead of creating new policy, it just updates the existing policy

Hound
  • 837
  • 17
  • 31

1 Answers1

0

Object replication asynchronously copies block blobs in a container according to rules that you configure.

When you configure object replication, you create a replication policy on the destination account via the Azure Storage resource provider. After the replication policy is created, Azure Storage assigns it a policy ID.

You are correct we can specify only 10 replication rules for each replication policy.

The problem which you are facing is actually not an issue but a limitation as a source account can replicate to no more than two destination accounts, with one policy for each destination account. Similarly, an account may serve as the destination account for no more than two replication policies. That's why your previous policy was getting updated.

You can check this Object Replication document from Microsoft for more information.

You can raise an Azure Support Ticket and check if they can increase the quota for policies.

SauravDas-MT
  • 1,224
  • 1
  • 4
  • 10