Azure blueprint deployment, getting Resource ID of publicIPAddresses of ACR Cluster

132 Views Asked by At

I have an Azure blueprint, which deploys an Azure ACR Cluster. Creating the cluster also triggers creating of the publicIPAddresses of the cluster. I need to get the Resource Id of that IP to be able to automate assigning a DNS/A record to that IP.

I thought about this output record in the artifact, which creates ACR Cluster:

"outputs": {
      "IPAddress": {
          "type": "string",
          "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))).id]"
        },
}

, which as I thought could help me dynamically get that Resource ID, but it doesn't seem to be working. Can somebody point, what am I doing wrong?

Thank you!

2

There are 2 best solutions below

0
Matthew On

Try adding 'Full' to your reference() function call, which instructs the call to return all properties, including the id.

see: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource?tabs=json#reference

0
Charles Xu On

Actually, if you only want to get the resource Id, you just need to use the function resourceId(), not the reference(). So the value of the outputs should like this:

"value": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"

Note that maybe you want to create an AKS cluster, the ACR is a Container Registry that stores the docker images and it does not need a public IP address.