azure template output publish profile content

2019-09-15 04:23发布

问题:

I'm using an Azure Template to set up a web site. I would like it to output the contents of the publish profile so that I can automate the deploying. Is this possible?

My current template looks something like this:

{
    ...
    "resources": [
        {
            "type": "Microsoft.Web/sites",
            "kind": "app",
            "name": "[variables('webapp').name]",
            "apiVersion": "[variables('webapp').version]",
            "location": "[variables('location')]",
            "tags": {},
            "properties": {
                "serverFarmId": "[variables('webapp').serviceplan.name]",
                "name": "[variables('webapp').name]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', variables('webapp').serviceplan.name)]"
            ]
        },
        {
            "type": "Microsoft.Web/serverfarms",
            "sku": {
                "name": "B1",
                "tier": "Basic",
                "size": "B1",
                "family": "B",
                "capacity": 1
            },
            "kind": "app",
            "name": "[variables('webapp').serviceplan.name]",
            "apiVersion": "[variables('webapp').serviceplan.version]",
            "location": "[variables('location')]",
            "properties": {
                "name": "[variables('webapp').serviceplan.name]",
                "numberOfWorkers": 1
            },
            "dependsOn": []
        }
    ],
    "outputs": {
        "manifest": {
            "type": "object",
            "value": {
                "Website": {
                    "publishUrl": "...",
                    "userPWD": "...",
                    "msdeploySite": "..."
                }
            }
        }
    }
}

I've tried experimenting with the listkeys function but as I understand it you need to give the id of the resource, i.e. publish profile, that you want to get and I'm not sure how to get that.

回答1:

you need to use reference and\or listkeys functions for that.

it would looks something like this:

"publishUrl": "[reference(variables('webapp').name)[%propertynamegoeshere%]]"

same goes for other things; but you need to use listkeys function to get keys for the webapp.