The Resource 'Microsoft.RecoveryServices/vaults/rsv-X' under resource group 'ResourceGroupB' was not found

Stefan Olivebring 1 Reputation point
2020-11-09T21:26:03.107+00:00

Hi

Using ARM template and in ResourceGroupA I have provisioned misc resources such as vnet etc and a recovery vault and its backup policies.

Using another ARM template and in ResourceGroupB im creating application resources such as VM, DB and a storage account and its file share. Here im getting a problem to add a Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems type using the existing vault created earlier ResourceGroupA

Extract from my ARM teamplate that im trying to deploy in ResourceGroupB:

"variables": {
    "namespace": "[tolower(replace(parameters('jiraBaseUrl'),'.', ''))]",
    "vault": {
        "name": "rsv-RiadaCloud",
        "policy": "DailyFileShare",
        "backupFabric": "Azure",
        "protectionContainers": "[array(concat('storagecontainer;storage;', parameters('vnetResourceGroup'), ';', variables('jira').storage.name))]",
        "protectedItems": "[array(concat('azurefileshare;', variables('jira').storage.sharedHomeName))]"
    },

...

    {
        "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
        "apiVersion": "2016-06-01",
        "name": "[concat(variables('vault').name, '/', variables('vault').backupFabric, '/', variables('vault').protectionContainers[copyIndex()], '/', variables('vault').protectedItems[copyIndex()])]",
        "properties": {
            "backupManagementType": "AzureStorage",
            "workloadType": "AzureFileShare",
            //"friendlyName": "afs",
            "protectedItemType": "AzureFileShareProtectedItem",
            "policyId": "[resourceId(parameters('vnetResourceGroup'), 'Microsoft.RecoveryServices/vaults/backupPolicies/', variables('vault').name, variables('vault').policy)]",
            "sourceResourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('jira').storage.name)]"
        },
        "copy": {
            "name": "protectedItemsCopy",
            "count": "[length(variables('vault').protectedItems)]"
        }
    }

The error message is:

Deployment failed. Correlation ID: 939a19e8-c2fd-4bc0-bb4a-058cf2929bb3. {
"error": {
"code": "ResourceNotFound",
"message": "The Resource 'Microsoft.RecoveryServices/vaults/rsv-RiadaCloud' under resource group 'ResourceGroupB' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
}
}

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,496 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Stefan Olivebring 1 Reputation point
    2020-11-18T10:18:43.11+00:00

    Attaching the json im currently using when testing ... gives me the error:

    $ az deployment group create --name ${URL} --mode Incremental --resource-group ${URL} --template-file test.json
    Deployment failed. Correlation ID: 52396cf0-749e-4aa2-a9d9-dddafc3f2926. {
    "error": {
    "code": "InvalidTemplate",
    "message": "Unable to process template language expressions for resource '/subscriptions/83f7f76b-2e53-47e6-ab3e-a036c62db934/resourceGroups/VPC/providers/Microsoft.Resources/deployments/nestedTemplateRecoveryServices' at line '89' and column '9'. 'The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Please see https://aka.ms/arm-copy for usage details.'",
    "additionalInfo": [
    {
    "type": "TemplateViolation",
    "info": {
    "lineNumber": 89,
    "linePosition": 9,
    "path": ""
    }
    }
    ]
    }
    }40599-testjson.txt

    0 comments No comments

  2. SadiqhAhmed-MSFT 49,331 Reputation points Microsoft Employee Moderator
    2020-12-04T17:00:12.527+00:00

    Updating the final answer for the benefit of community!

    The option to select a resource group for the vault other than the one being used during deployment is not supported as part of the published ARM template to enable backup for AFS. This means that you will have to deploy the templates for file share creation and configuring backup separately.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.