title: Add VM to Recovery Services Vault in different Resource Group
body: <p>I'm fairly new to Azure ARM Templates so any help it's appreciated.  I'm trying to deploy various vm's and at the same time configure the backup but I'm getting this error:</p>
  <p>&quot;InvalidTemplate&quot;,&quot;message&quot;:&quot;Deployment template validation failed: 'The template resource '[concat(parameters('VMNames')[copyIndex()], '-' , 'BackupIntent')]' at line '195' and column '9' is not valid: The language expression property '0' can't be evaluated.</p>
  <pre><code>{
    &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,
    &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
    &quot;parameters&quot;: {
      &quot;VnetResourceGroup&quot;: {
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;VnetName&quot;: {
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;SubnetName&quot;: {
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;OSVersion&quot;: {
        &quot;defaultValue&quot;: &quot;2016-Datacenter&quot;,
        &quot;allowedValues&quot;: [
          &quot;2016-Datacenter&quot;,
          &quot;2019-Datacenter&quot;,
          &quot;2022-datacenter&quot;,
          &quot;2022-datacenter-g2&quot;,
          &quot;2019-datacenter-gensecond&quot;,
          &quot;2016-datacenter-gensecond&quot;
        ],
        &quot;type&quot;: &quot;String&quot;,
        &quot;metadata&quot;: {
          &quot;description&quot;: &quot;The Windows version for the VM. This will pick a fully patched image of this given Windows version.&quot;
        }
      },
      &quot;virtualMachineSize&quot;: {
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;AdminUsername&quot;: {
        &quot;defaultValue&quot;: &quot;evtcladm&quot;,
        &quot;type&quot;: &quot;String&quot;,
        &quot;metadata&quot;: {
          &quot;description&quot;: &quot;Admin username for VM&quot;
        }
      },
      &quot;AdminPassword&quot;: {
        &quot;type&quot;: &quot;SecureString&quot;,
        &quot;metadata&quot;: {
          &quot;description&quot;: &quot;Admin password for VM&quot;
        }
      },
      &quot;backupVaultName&quot;: {
        &quot;defaultValue&quot;: &quot;vault-corenet-01&quot;,
        &quot;allowedValues&quot;: [
          &quot;vault-corenet-01&quot;,
          &quot;vault-cps-01&quot;,
          &quot;Vault-Multi-VM&quot;,
          &quot;Vault-RecoveryMultiVM&quot;,
          &quot;vault-evt-cps-chile&quot;
        ],
        &quot;type&quot;: &quot;String&quot;,
        &quot;metadata&quot;: {
          &quot;description&quot;: &quot;Recovery Vault to be used for backup&quot;
        }
      },
      &quot;BackupPolicy&quot;: {
        &quot;defaultValue&quot;: &quot;FASE1&quot;,
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;RSVResourceGroup&quot;: {
          &quot;type&quot;: &quot;String&quot;
      },
      &quot;backupFabricName&quot;: {
        &quot;defaultValue&quot;: &quot;Azure&quot;,
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;VMNames&quot;: {
        &quot;type&quot;: &quot;String&quot;
      },
      &quot;numberOfInstances&quot;: {
        &quot;type&quot;: &quot;Int&quot;,
        &quot;metadata&quot;: {
          &quot;description&quot;: &quot;Number of VMs to deploy&quot;
        }
      }
    },
    &quot;variables&quot;: {
      &quot;v2Vm&quot;: &quot;vm;iaasvmcontainerv2;&quot;,
      &quot;maxZones&quot;: 3,
      &quot;nicSuffix&quot;: &quot;NIC&quot;,
      &quot;networkInterfaceName&quot;: &quot;[concat(parameters('VMNames'), variables('nicSuffix'))]&quot;
    },
    &quot;resources&quot;: [
      {
        &quot;type&quot;: &quot;Microsoft.Network/networkInterfaces&quot;,
        &quot;apiVersion&quot;: &quot;2016-03-30&quot;,
        &quot;name&quot;: &quot;[concat(variables('networkInterfaceName'), copyindex(1))]&quot;,
        &quot;location&quot;: &quot;[resourceGroup().location]&quot;,
        &quot;properties&quot;: {
          &quot;ipConfigurations&quot;: [
            {
              &quot;name&quot;: &quot;ipconfig1&quot;,
              &quot;properties&quot;: {
                &quot;privateIPAllocationMethod&quot;: &quot;Dynamic&quot;,
                &quot;subnet&quot;: {
                  &quot;id&quot;: &quot;[resourceId(parameters('VnetResourceGroup'),'Microsoft.Network/virtualNetworks/subnets',parameters('VnetName'),parameters('subnetName'))]&quot;
                }
              }
            }
          ]
        },
        &quot;copy&quot;: {
          &quot;name&quot;: &quot;nicLoop&quot;,
          &quot;count&quot;: &quot;[parameters('numberOfInstances')]&quot;
        }
      },
      {
        &quot;type&quot;: &quot;Microsoft.Compute/virtualMachines&quot;,
        &quot;apiVersion&quot;: &quot;2016-04-30-preview&quot;,
        &quot;name&quot;: &quot;[concat(parameters('VMNames'), copyIndex(1))]&quot;,
        &quot;location&quot;: &quot;[resourceGroup().location]&quot;,
        &quot;dependsOn&quot;: [
          &quot;nicLoop&quot;
        ],
        &quot;zones&quot;: [
          &quot;[string(add(mod(copyIndex(0), variables('maxZones')), 1))]&quot;
        ],
        &quot;properties&quot;: {
          &quot;hardwareProfile&quot;: {
            &quot;vmSize&quot;: &quot;[parameters('virtualMachineSize')]&quot;
          },
          &quot;osProfile&quot;: {
            &quot;computerName&quot;: &quot;[concat(parameters('VMNames'), copyIndex(1))]&quot;,
            &quot;adminUsername&quot;: &quot;[parameters('AdminUsername')]&quot;,
            &quot;adminPassword&quot;: &quot;[parameters('AdminPassword')]&quot;
          },
          &quot;storageProfile&quot;: {
            &quot;imageReference&quot;: {
              &quot;publisher&quot;: &quot;MicrosoftWindowsServer&quot;,
              &quot;offer&quot;: &quot;WindowsServer&quot;,
              &quot;sku&quot;: &quot;[parameters('OSVersion')]&quot;,
              &quot;version&quot;: &quot;latest&quot;
            },
            &quot;osDisk&quot;: {
              &quot;createOption&quot;: &quot;FromImage&quot;,
              &quot;managedDisk&quot;: {
                &quot;storageAccountType&quot;: &quot;Premium_LRS&quot;
              }
            }
          },
          &quot;networkProfile&quot;: {
            &quot;networkInterfaces&quot;: [
              {
                &quot;id&quot;: &quot;[resourceId('Microsoft.Network/networkInterfaces', concat(variables('networkInterfaceName'), copyindex(1)))]&quot;
              }
            ]
          }
        },
        &quot;copy&quot;: {
          &quot;name&quot;: &quot;virtualMachineLoop&quot;,
          &quot;count&quot;: &quot;[parameters('numberOfInstances')]&quot;
        }
      },
      {
    &quot;apiVersion&quot;: &quot;2017-05-10&quot;,
    &quot;name&quot;: &quot;[concat(parameters('VMNames')[copyIndex()], '-' , 'BackupIntent')]&quot;,
    &quot;type&quot;: &quot;Microsoft.Resources/deployments&quot;,
    &quot;resourceGroup&quot;: &quot;[parameters('RSVResourceGroup')]&quot;,
    &quot;copy&quot;: {
      &quot;name&quot;: &quot;AzureBackupLoop&quot;,
      &quot;count&quot;: &quot;[length(parameters('VMNames'))]&quot;
    },
    &quot;dependsOn&quot;: [
      &quot;virtualMachineLoop&quot;
    ],
    &quot;properties&quot;: {
      &quot;mode&quot;: &quot;Incremental&quot;,
      &quot;template&quot;: {
        &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,
    &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
        &quot;resources&quot;: [
          {
            &quot;name&quot;: &quot;[concat(parameters('backupVaultName'), '/', 'Azure', '/', variables('v2Vm'), resourceGroup().name, ';', parameters('VMNames')[copyIndex()])]&quot;,
            &quot;apiVersion&quot;: &quot;2017-07-01&quot;,
            &quot;type&quot;: &quot;Microsoft.RecoveryServices/vaults/backupFabrics/backupProtectionIntent&quot;,
            &quot;properties&quot;: {
              &quot;friendlyName&quot;: &quot;[concat(parameters('VMNames')[copyIndex()], 'BackupIntent')]&quot;,
              &quot;protectionIntentItemType&quot;: &quot;AzureResourceItem&quot;,
              &quot;policyId&quot;: &quot;[resourceId(parameters('RSVResourceGroup'), 'Microsoft.RecoveryServices/vaults/backupPolicies', parameters('backupVaultName'), parameters('BackupPolicy'))]&quot;,
              &quot;sourceResourceId&quot;: &quot;[resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', parameters('VMNames')[copyIndex()])]&quot;
            }
          }
        ]
      }
    }
  }
    ]
  }   
  </code></pre>