custom/webappv4.template.json

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "botEnv": {
            "type": "string",
            "defaultValue": "prod"
        },
        "botId": {
            "type": "string"
        },
        "description": {
            "type": "string",
            "defaultValue": ""
        },
        "location": {
            "type": "string"
        },
        "sku": {
            "type": "string"
        },
        "kind": {
            "type": "string"
        },
        "siteName": {
            "type": "string"
        },
        "appId": {
            "type": "string",
            "defaultValue": "1234"
        },
        "appSecret": {
            "type": "string",
            "defaultValue": "blank"
        },
        "zipUrl": {
            "type": "string",
            "defaultValue": ""
        },
        "serverFarmId": {
            "type": "string"
        },
        "createServerFarm": {
            "type": "bool"
        },
        "serverFarmLocation": {
            "type": "string",
            "defaultValue": ""
        },
        "serverFarmSku": {
            "type": "object",
            "defaultValue": {
                "name": "S1",
                "tier": "Standard",
                "size": "S1",
                "family": "S",
                "capacity": 1
            }
        },
        "endpoint": {
            "type": "string",
            "defaultValue": ""
        },
        "botFileEncryptionKey": {
            "type": "string",
            "defaultValue": ""
        }
    },
    "variables": {
        "serverFarmName": "[last(split(parameters('serverFarmId'), '/'))]",
        "botAppKinds": {
            "sdk": "app",
            "bot": ""
        },
        "botAppKind": "[variables('botAppKinds')[parameters('kind')]]",
        "siteHost": "[concat(parameters('siteName'), '.azurewebsites.net')]",
        "botEndpointConfig": {
            "bot": "[parameters('endpoint')]",
            "sdk": "[concat('https://', variables('siteHost'), '/api/messages')]"
        },
        "botEndpoint": "[variables('botEndpointConfig')[parameters('kind')]]"
    },
    "resources": [
        {
            "type": "Microsoft.Web/serverfarms",
            "condition": "[parameters('createServerFarm')]",
            "name": "[variables('serverFarmName')]",
            "apiVersion": "2016-09-01",
            "location": "[parameters('serverFarmLocation')]",
            "sku": "[parameters('serverFarmSku')]",
            "properties": {
                "name": "[variables('serverFarmName')]"
            }
        },
        {
            "name": "[parameters('siteName')]",
            "type": "Microsoft.Web/sites",
            "apiVersion": "2015-08-01",
            "location": "[parameters('location')]",
            "kind": "[variables('botAppKind')]",
            "dependsOn": [
                "[parameters('serverFarmId')]"
            ],
            "properties": {
                "name": "[parameters('siteName')]",
                "serverFarmId": "[parameters('serverFarmId')]",
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "WEBSITE_NODE_DEFAULT_VERSION",
                            "value": "10.14.1"
                        },
                        {
                            "name": "MicrosoftAppId",
                            "value": "[parameters('appId')]"
                        },
                        {
                            "name": "MicrosoftAppPassword",
                            "value": "[parameters('appSecret')]"
                        }
                    ],
                    "cors": {
                        "allowedOrigins": [
                            "https://botservice.hosting.portal.azure.net",
                            "https://hosting.onecloud.azure-test.net/"
                        ]
                    }
                }
            },
            "resources": [
                {
                    "name": "MSDeploy",
                    "type": "Extensions",
                    "apiVersion": "2015-02-01",
                    "condition": "[not(equals(parameters('zipUrl'), ''))]",
                    "dependsOn": [
                        "[concat('Microsoft.Web/Sites/', parameters('siteName'))]"
                    ],
                    "properties": {
                        "packageUri": "[parameters('zipUrl')]",
                        "dbType": "None",
                        "connectionString": "",
                        "setParameters": {
                            "IIS Web Application Name": "[parameters('siteName')]"
                        }
                    }
                }
            ]
        },
        {
            "apiVersion": "2017-12-01",
            "type": "Microsoft.BotService/botServices",
            "name": "[parameters('botId')]",
            "location": "global",
            "kind": "[parameters('kind')]",
            "sku": {
                "name": "[parameters('sku')]"
            },
            "properties": {
                "name": "[parameters('botId')]",
                "displayName": "[parameters('botId')]",
                "endpoint": "[variables('botEndpoint')]",
                "msaAppId": "[parameters('appId')]",
                "publishingCredentials": "[list(concat(resourceId('Microsoft.Web/Sites', parameters('siteName')), '/config/publishingcredentials'), '2018-02-01')]",
                "allSettings": {
                    "WEBSITE_NODE_DEFAULT_VERSION": "10.14.1",
                    "SCM_DO_BUILD_DURING_DEPLOYMENT": "true",
                    "BotId": "[parameters('botId')]",
                    "MicrosoftAppId": "[parameters('appId')]",
                    "MicrosoftAppPassword": "[parameters('appSecret')]",
                    "botFilePath": "[concat('./', parameters('botId'), '.bot')]",
                    "botFileSecret": "[parameters('botFileEncryptionKey')]",
                    "description": "[parameters('description')]"
                }
            },
            "dependsOn": [
                "[parameters('serverFarmId')]",
                "[resourceId('Microsoft.Web/sites/', parameters('siteName'))]",
                "MSDeploy"
            ]
        }
    ]
}