1

I'm trying to deploy two VMs in an avset using Visual Studio 2015.

I get the error message below when I attempt to deploy:

Reference Id 1 is not formatted correctly. The Id is expected to reference resources of type virtualNetworks/subnets. Path properties.ipConfigurations[0].properties.subnet.

Full error:

VERBOSE: 11:43:00 PM - Resource Microsoft.Compute/availabilitySets 'avset-apps2dc' provisioning status is succeeded
New-AzureRmResourceGroupDeployment : 11:43:00 PM - Resource Microsoft.Network/networkInterfaces 'vm-machine2-nic1' failed with message '{
  "error": {
    "code": "InvalidRequestFormat",
    "message": "Cannot parse the request.",
    "details": [
      {
        "code": "InvalidJsonReferenceFormat",
        "message": "Reference Id 1 is not formatted correctly. The Id is expected to reference resources of type virtualNetworks/subnets. Path properties.ipConfigurations[0].properties.subnet."
      }

It's really got me stumped and I was wondering if anyone has come across this before?

The scripts have been sanitised.

Template file:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "stdAdminUserName": {
      "type": "string",
      "minLength": 1
    },
    "stdAdminPassword": {
      "type": "securestring"
    },
    "storageAccountName": {
      "type": "string",
      "minLength": 1
    },
    "storageAccountType": {
      "type": "string",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS"
      ]
    },
    "faultDomains": {
      "type": "int"
    },
    "updateDomains": {
      "type": "int"
    },
    "applicationid": {
      "type": "string",
      "minLength": 1
    },
    "sharedservice": {
      "type": "string",
      "minLength": 1
    },
    "msdref": {
      "type": "string",
      "minLength": 1
    },
    "project": {
      "type": "string",
      "minLength": 1
    },
    "costcentre": {
      "type": "string",
      "minLength": 1
    },
    "templateref": {
      "type": "string",
      "minLength": 1
    },
    "environment": {
      "type": "string",
      "minLength": 1
    },
    "operatingsystem": {
      "type": "string",
      "minLength": 1
    },
    "deploymentzone": {
      "type": "string",
      "minLength": 1
    },
    "shutdownschedule": {
      "type": "string",
      "minLength": 1
    },
    "avSetName": {
      "type": "string",
      "minLength": 1
    },
    "vmInstances": {
      "type": "int"
    },
    "vmSize": {
      "type": "string",
      "minLength": 1
    },
    "vmDiskSize": {
      "type": "string",
      "minLength": 1
    },
    "networkName": {
      "type": "string",
      "minLength": 1
    },
    "networkResourceGroup": {
      "type": "string",
      "minLength": 1
    },
    "subnetName": {
      "type": "string",
      "minLength": 1
    },
    "vmNicNamePrefix": {
      "type": "string",
      "minLength": 1
    },
    "vmNamePrefix": {
      "type": "string",
      "minLength": 1
    }
  },
  "variables": {
    "VNetID": "[resourceId(Parameters('networkResourceGroup'), 'Microsoft.Network/virtualNetworks', Parameters('networkname'))]",
    "SubnetRef": "[concat(variables('VNetID'), '/subnets/', Parameters('subnetName'))]",
    "stdVMImagePublisher": "MicrosoftWindowsServer",
    "stdVMImageOffer": "WindowsServer",
    "stdWindowsOSVersion": "2012-R2-Datacenter",
    "stdVHDContainerName": "vhds",
    "VMOSDiskNamePrefix": "VMOSDisk",
    "VMDATADisk1NamePrefix": "DataDisk1VM",
    "VMDATADisk2NamePrefix": "DataDisk2VM"
  },
  "resources": [
    {
      "name": "[Parameters('storageAccountName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-06-15",
      "dependsOn": [],
      "tags": {
        "displayname": "[Parameters('storageAccountName')]",
        "applicationid": "[Parameters('applicationid')]",
        "sharedservice": "[Parameters('sharedservice')]",
        "msdref": "[Parameters('msdref')]",
        "project": "[Parameters('project')]",
        "costcentre": "[Parameters('costcentre')]",
        "operatingsystem": "[Parameters('operatingsystem')]",
        "deploymentzone": "[Parameters('deploymentzone')]",
        "shutdownschedule": "[Parameters('shutdownschedule')]"
      },
      "properties": {
        "accountType": "[Parameters('storageAccountType')]"
      }
    },
    {
      "name": "[parameters('avSetName')]",
      "type": "Microsoft.Compute/availabilitySets",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-06-15",
      "dependsOn": [],
      "tags": {
        "displayName": "[parameters('avSetName')]"
      },
      "properties": {
        "platformUpdateDomainCount": "[parameters('updateDomains')]",
        "platformFaultDomainCount": "[parameters('faultDomains')]"
      }
    },
    {
      "name": "[concat(Parameters('vmNicNamePrefix'), copyindex(1))]",
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-06-15",
      "copy": {
        "name": "nicLoop",
        "count": "[parameters('vmInstances')]"
      },
      "tags": {
        "costcenter": "[Parameters('costcentre')]",
        "environment": "[Parameters('environment')]",
        "project": "[Parameters('project')]",
        "role": "vmnic",
        "templateref": "[Parameters('templateRef')]"
      },
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "subnet": {
                "id": "[parameters('vmInstances')]"
              }
            }
          }
        ]
      }
    },
    {
      "name": "[concat(parameters('vmInstances'), copyindex(1))]",
      "type": "Microsoft.Compute/virtualMachines",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-06-15",
      "dependsOn": [
        "[concat('Microsoft.Storage/storageAccounts/', Parameters('storageAccountName'))]",
        "[concat('Microsoft.Compute/availabilitySets/', Parameters('avSetName'))]",
        "nicLoop"
      ],
      "copy": {
        "name": "virtualMachineLoop",
        "count": "[parameters('vmInstances')]"
      },
      "tags": {
        "applicationid": "[Parameters('applicationid')]",
        "costcentre": "[Parameters('costcentre')]",
        "deploymentzone": "[Parameters('deploymentzone')]",
        "displayname": "[concat(parameters('vmInstances'), copyindex(1))]",
        "environment": "[Parameters('environment')]",
        "msdref": "[Parameters('msdref')]",
        "operatingsystem": "[Parameters('operatingsystem')]",
        "project": "[Parameters('project')]",
        "sharedservice": "[Parameters('sharedservice')]"
      },
      "properties": {
        "availabilitySet": {
          "id": "[resourceId('Microsoft.Compute/availabilitySets',parameters('avSetName'))]"
        },
        "hardwareProfile": {
          "vmSize": "[Parameters('vmSize')]"
        },
        "osProfile": {
          "computerName": "[concat(parameters('vmInstances'), copyindex(1))]",
          "adminUsername": "[Parameters('stdAdminUserName')]",
          "adminPassword": "[Parameters('stdAdminPassword')]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "[variables('STDVMImagePublisher')]",
            "offer": "[variables('STDVMImageOffer')]",
            "sku": "[variables('stdWindowsOSVersion')]",
            "version": "latest"
          },
          "osDisk": {
            "name": "[concat(variables('VMOSDiskNamePrefix'), copyindex(1))]",
            "vhd": {
              "uri": "[concat('http://', Parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdVHDContainerName'), '/', variables('VMOSDiskNamePrefix'), copyindex(1), '.vhd')]"
            },
            "caching": "ReadWrite",
            "createOption": "FromImage"
          },
          "networkProfile": {
            "networkInterfaces": [
              {
                "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(Parameters('vmNicNamePrefix'), copyindex(1)))]"
              }
            ]
          }

        },
        "outputs": {
        }
      }
    }
  ]
}

Parameters file:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "stdAdminUserName": {
      "value": "localadministrator"
    },
    "storageAccountName": {
      "value": "straccforvhdsnstuff1234"
    },
    "storageAccountType": {
      "value": "Standard_LRS"
    },
    "faultDomains": {
      "value": 2
    },
    "updateDomains": {
      "value": 5
    },
    "applicationid": {
      "value": "test-apps2"
    },
    "sharedservice": {
      "value": "No"
    },
    "msdref": {
      "value": "123456"
    },
    "project": {
      "value": "test-apps2"
    },
    "costcentre": {
      "value": "ab1234"
    },
    "operatingsystem": {
      "value": "Windows 2012-R2-Datacenter"
    },
    "deploymentzone": {
      "value": "safe-zone"
    },
    "avSetName": {
      "value": "avset-apps2dc"
    },
    "vmInstances": {
      "value": 1
    },
    "vmSize": {
      "value": "Standard_D3_V2"
    },
    "vmDiskSize": {
      "value": "256"
    },
    "networkName": {
      "value": "vnet-network"
    },
    "networkResourceGroup": {
      "value": "rgp-for-network"
    },
    "subnetName": {
      "value": "subnettest-app2"
    },
    "vmNicNamePrefix": {
      "value": "vm-machine2-nic"
    },
    "vmNamePrefix": {
      "value": "vm-machine2-"
    },
    "templateref": {
      "value": "tempref123"
    },
    "environment": {
      "value": "green"
    },
    "shutdownschedule": {
      "value": "notapp"
    }
  }
}

I have run the JSON through online validators and no problems highlighted, there are no errors in the script according to VS2015. However, the deployment fails "reference 1 not formatted properly"

One more point, not sure how much it applies, the networking resource group is independent of the VM resource group.

  • Hi, In order to better locate the problem, could you share your full template? – Shui shengbao Nov 14 '17 at 1:09
  • @Walter-MSFT Hi Walter, thanks for getting back to me, I've updated the template file with the full script. also made a note about the network resources all being housed in a separate resource group. Could it be that it;s not somehow connecting to that and I need to specify the full path such as [resourceid(variables('VNetID'), '/subnets/', Parameters('subnetName'))]" – Norrin Rad Nov 14 '17 at 1:25
  • Hi, the error is tell you 1 could not set subnet id value. You could check your template [parameters('vmInstances')] the value is 1. – Shui shengbao Nov 14 '17 at 2:03
1

There is a mistake in your template.

 "subnet": {
                "id": "[parameters('vmInstances')]"
              }

The id should not be 1.

You could use value:

  "id": "[variables('SubnetRef')]"
| improve this answer | |
  • You could check this example. – Shui shengbao Nov 14 '17 at 1:59
  • Thanks Walter, that's moved forward, managed to create the nics now too, but fails on vm's with the error "New-AzureRmResourceGroupDeployment : 2:03:59 AM - Resource Microsoft.Compute/virtualMachines '31' failed with message '{ "error": { "details": [ { { "target": "vm.properties.storageProfile.networkProfile", "message": "Could not find member 'networkProfile' on object of type 'StorageProfile'. Path 'properties.storageProfile.networkProfile', line 1, position 893." }, – Norrin Rad Nov 14 '17 at 2:08
  • "target": "vm.properties.outputs", "message": "Could not find member 'outputs' on object of type 'Properties'. Path 'properties.outputs', line 1, position 1072." } ], "code": "BadRequest", "message": "The request message is invalid." } – Norrin Rad Nov 14 '17 at 2:08
  • Hi, this is a different error log, you could accept my answer and ask a new question. The error log in comment is hard to read. – Shui shengbao Nov 14 '17 at 2:10
  • Yeh sure, thanks for your help with the original question :) – Norrin Rad Nov 14 '17 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.