custom/webappv4.template.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
{
    "$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"
            ]
        }
    ]
}