5

I would like the public IP address from an App Service deployed from an ARM Template like the simplified one below. I've seen examples of getting the public inbound IP address from an API Gateway, VNET of a VM, App Service Environment, etc., but I haven't found anything that indicates how to get it out of a simple App Service deployment. I find navigating the ARM API, and how that translates into a string into a JSON file, rather byzantine. Any assistance would be appreciated.

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appServiceName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Specifies the name of the Azure App Service"
            }
        },
        "appServicePlanName": {
            "type": "string",
            "minLength": 1
        }
    },
    "variables": {
    },
    "resources": [
        {
            "apiVersion": "2015-08-01",
            "name": "[parameters('appServiceName')]",
            "type": "Microsoft.Web/sites",
            "kind": "app",
            "location": "[resourceGroup().location]",
            "dependsOn": [],
            "properties": {
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
                "clientAffinityEnabled": false
            },
            "resources": [],
        }
    ],
    "outputs": {
        "appServiceName": {
            "type": "string",
            "value": "[parameters('appServiceName')]"
        },
        "ipAddress": {
            "type": "string",
            "value": "whatingodsnamegoeshere"
        }
    }
}

1 Answer 1

6

you need to use reference() function and give it resource id or just the name if the resource is in the same template:

reference(parameters('appServiceName'), '2016-03-01', 'Full').properties.inboundIpAddress

or with resourceId():

reference(resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName')), '2016-03-01', 'Full').properties.inboundIpAddress
Sign up to request clarification or add additional context in comments.

4 Comments

When I first read your answer it sounded "guessy" but after having outputted all the properties I see that "possibleOutboundIpAddresses" is actually a thing. Ha. Having read your answer, it suddenly occurred to me that I could output all the properties available to see what's there. So, thanks for that. I was actually looking for the inboundIpAddress. I just clarified the question. If you'll revise your answer in light of the edit, I'll accept it.
why would I post "guessy" answers? updated the answer
¯_(ツ)_/¯. Accepted.
I made it working by referencing app service, not app service plan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.