irom
irom

Reputation: 3606

How to reference static IP address in ARM template?

I have public static IP address with name 'VPNPublicIP' in resource group. How to reference this address in below ARM template ? I don't want to this static to change

 "resources": [
{
      "apiVersion": "[variables('apiVersion')]",
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[variables('WebPublicIPName')]",
      "location": "[variables('location')]",
      "properties": {
        "privateIPAllocationMethod": "Static",
        "publicIPAddress": "VPNPublicIP",

      }
    }
}

I believe the one above is not correct, please advice

Upvotes: 1

Views: 1052

Answers (2)

Charles Xu
Charles Xu

Reputation: 31454

You can reference the existing public IP to another resource with its resource Id:

"publicIPAddress": {
       "id":"[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
 },

Upvotes: 2

4c74356b41
4c74356b41

Reputation: 72191

You dont have to reference it in the same resource, you just need to set its privateIPAllocationMethod property to static and thats it. it will be created as a static ip address.

{
    "apiVersion": "[variables('apiVersion')]",
    "type": "Microsoft.Network/publicIPAddresses",
    "name": "[variables('WebPublicIPName')]",
    "location": "[variables('location')]",
    "properties": {
        "privateIPAllocationMethod": "Static"
    }
}

if you want to attach it to something you can use the resourceId() function as the other answer suggests.

Upvotes: 1

Related Questions