title: Get public IP address of API Management from ARM template
body: <p>I got this API Management ARM template </p>
  
  <pre><code>{
        "apiVersion": "2017-03-01",
        "name": "[variables('am-apimanagement-service-name')]",
        "type": "Microsoft.ApiManagement/service",
        "location": "North Europe",
        "sku": {
          "name": "[parameters('am-sku')]",
          "capacity": "[parameters('am-skuCount')]"
        },
        "properties": {
          "publisherEmail": "[parameters('am-publisher-email-p')]",
          "publisherName": "[parameters('am-publisher-name-p')]"
        },
        "resources": [
          {
            "type": "apis",
            "apiVersion": "2017-03-01",
            "name": "test",
            "dependsOn": [
              "[concat('Microsoft.ApiManagement/service/',variables('am-apimanagement-service-name'))]"
            ],
            "properties": {
              "displayName": "test",
              "description": "",
              "serviceUrl": "[concat('https://test-',parameters('environment'),'.azurewebsites.net')]",
              "path": "test",
              "protocols": [
                "https"
              ],
              "isCurrent": true
            },
            "resources": [
              {
                "apiVersion": "2017-03-01",
                "type": "operations",
                "name": "GetTEst",
                "dependsOn": [
                  "[concat('Microsoft.ApiManagement/service/', variables('am-apimanagement-service-name'), '/apis/test')]"
                ],
                "properties": {
                  "displayName": "GET",
                  "method": "GET",
                  "urlTemplate": "/api/sites",
                  "description": "Get"
                }
              }
            ]
  
          }
        ]
      }
  </code></pre>
  
  <p>And this Web API ARM template</p>
  
  <pre><code>   {
        "apiVersion": "2016-03-01",
        "name": "[variables('swa-name')]",
        "type": "Microsoft.Web/sites",
        "properties": {
          "name": "[variables('swa-name')]",
          "serverFarmId": "[variables('swa-hosting-plan-name')]",
          "hostingEnvironment": "[parameters('swa-hosting-environment')]",
          "siteConfig": {
            "appSettings": [
              {
                "name": "Test:ConnectionString",
                "value": "[concat('Server=tcp:', reference(resourceId('Microsoft.Sql/servers/', variables('db-serverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('db-databaseName'), ';Persist Security Info=False;User ID=', parameters('db-administratorLogin'), ';Password=', parameters('db-administratorLoginPassword'), ';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;')]"
              }
            ],
            "ipSecurityRestrictions": [
              {
                "ipAddress": "[variables('test-ip-address')]",
                "subnetMask": "255.255.255.255"
              }
            ]
          }
        },
        "location": "[parameters('swa-location')]",
        "tags": {
  
        },
        "kind": "api",
        "dependsOn": [
          "[concat('Microsoft.Web/serverfarms/', variables('swa-hosting-plan-name'))]"
        ]
      }
  </code></pre>
  
  <p>How do I use the reference function to get IP address of the API Management resource from the Web API ? I want to put the API Management IP address in the ipSecurityRestrictions. I can not figure it out, and it is frustrating me quite a bit.</p>
  
  <p>I have tried this from the web api resource resource section of the ARM template:</p>
  
  <pre><code>"ipSecurityRestrictions": [
              {
                "ipAddress": "[variables('test-ip-address')]",
                "subnetMask": "255.255.255.255"
              },
              {
                "ipAddress": "[reference(variables('am-apimanagement-service-name')).publicIPAddresses[0]]",
                "subnetMask": "255.255.255.255"
              }
            ]
  </code></pre>
  
  <p>But it doesnt work. Maybe I am not able to get the IP address in this step of the process? I am reading about outputs and linked templates. Maybe this is the solution?</p>