1

I have a VMSS deployed with am ARM template.

I want add it's first VM's IP address to the output.

In the Azure Resource Explorer - I see resource as:

...
        "ipConfigurations": [
          {
            "name": "jm-website-script-4-master-ip",
            "id": "/subscriptions/0a4f2b9c-***-40b17ef8c3ab/resourceGroups/jm-website-script-4/providers/Microsoft.Compute/virtualMachineScaleSets/jm-website-script-4-master-vmss/virtualMachines/1/networkInterfaces/jm-website-script-4-master-nic/ipConfigurations/jm-website-script-4-master-ip",
            "etag": "W/\"09be80d2-76f5-49fc-ad47-0ef836a3799a\"",
            "properties": {
              "provisioningState": "Succeeded",
              "privateIPAddress": "10.0.0.5",
...

So I tried to add to the variables:

"masterVM": "[concat('Microsoft.Compute/virtualMachineScaleSets/jm-website-script-4-master-vmss/virtualMachines/1/networkInterfaces/jm-website-script-4-master-nic/ipConfigurations/jm-website-script-4-master-ip')]",

And then call in outputs:

  "outputs": {
    "MasterFirstIPConfig": {
      "type": "string",
      "value": "[reference(variables('masterVM').properties.privateIPAddress)]"
    }
  }

Which returns me an error:

The language expression property 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Expression.Expressions.JTokenExpression' can't be evaluated..

I guess something is completely wrong with my masterVM variable definition here, but can't get it.

UPD The solution

Thanks for the answer by 4c74356b41.

The solution looks like next:

variable definition:

"masterVM": "Microsoft.Compute/virtualMachineScaleSets/jm-website-script-4-master-vmss/virtualMachines/1/networkInterfaces/jm-website-script-4-master-nic"

outputs:

  "outputs": {
   "MasterFirstIPConfig": {
     "type": "string",
     "value": "[reference(variables('masterVM'),'2016-09-01').ipConfigurations[0].properties.privateIPAddress]"
   }
 }
Community
  • 1
  • 1
setevoy
  • 4,374
  • 11
  • 50
  • 87
  • Not sure you can do this, because in Azure Resource Explorer it's a call to the Network resource provider which returns the network interface information (even though it's in the VMSS namespace), but the variable definition is going through the Compute stack. You could get the IP addresses externally, e.g. with PowerShell like.. (Get-AzureRmNetworkInterface -VirtualMachineScaleSetName $VMSSName -ResourceGroupName $RG -VirtualMachineIndex 0).IpConfigurations[0].PrivateIpAddress What's the output being used for? Maybe there's another way to do get what you need. – sendmarsh Mar 14 '17 at 16:56
  • @sendmarsh Thanks for your comment. IP need to be used for Docker Swarm initialization process (join workers). So I'm trying to get Master's IP into ARM's variable and then pass it to the `bash` script in the `CustomScript` extension. I tried to find a way to get IP with Azure CLI, but... No luck, shortly. – setevoy Mar 14 '17 at 17:32

1 Answers1

2

Well, you are targeting the wrong resource. You should be targeting the networkInterface (and you don't need to concat in this case), you also have to reference it properly:

"masterVM": "Microsoft.Compute/virtualMachineScaleSets/jm-website-script-4-master-vmss/virtualMachines/1/networkInterfaces/jm-website-script-4-master-nic]"

And reference like so

"value": "[reference(variables('masterVM'),'2016-09-01').ipConfigurations[0].properties.privateIPAddress]"
4c74356b41
  • 69,186
  • 6
  • 100
  • 141