0

I am getting the following error when implementing ARM template with availability set '/subscriptions/xxx/resourceGroups/mgRG/providers/Microsoft.Compute/virtualMachines/myVM'. "Unable to evaluate template language function 'resourceId': all function arguments must be string literals"

"availabilitySet": {
                    "id": "[resourceId(subscription(),parameters('RGName'),'Microsoft.Compute/availabilitySets',variables('ASName'))]"

I tried to remove subscription() from parameters, didn't help. I have to keep parameters('RGName') because it is not current Resource Group.

irom
  • 3,316
  • 14
  • 54
  • 86

1 Answers1

1

Well, it is what it is, it only accepts strings.

  1. subscription() would return an object, not a string.
  2. Since you are using subscription() it means you are targeting the same subscription, you can just drop this part.
  3. parameters('RGName') - is only needed if the resource is in another resource group. It has to be a string as well.
  4. variables('ASName') - has to be a string as well.

If it complains something is not a string, then something is not a string :)

Svante Svenson
  • 12,315
  • 4
  • 41
  • 45
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Right, better after remove subscription(). But now "Entity resourceGroupName in resource reference id /subscriptions/xxx/resourceGroups/myRG/providers/Microsoft.Compute/availabilitySets/myAS is invalid while this is exactly correct resource ID, compared char by char – irom Mar 14 '19 at 19:11
  • 1
    i think its not supported: https://stackoverflow.com/questions/35778323/can-i-put-vm-into-another-resource-group-than-availabilityset – 4c74356b41 Mar 14 '19 at 19:13