From e7e3e4327b4fa780f019b4e6f6780872f7caed64 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 11:18:48 -0700 Subject: [PATCH 1/8] Add stub for functions ARM resource --- .../template-function-bot-resources.json | 210 ++++++++++++++++++ .../yaml/deployBotResources/dotnet/deploy.yml | 71 ++++-- 2 files changed, 259 insertions(+), 22 deletions(-) create mode 100644 build/templates/template-function-bot-resources.json diff --git a/build/templates/template-function-bot-resources.json b/build/templates/template-function-bot-resources.json new file mode 100644 index 0000000000..de5faada36 --- /dev/null +++ b/build/templates/template-function-bot-resources.json @@ -0,0 +1,210 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings." + } + }, + "botName": { + "type": "string" + }, + "botLocation": { + "type": "string" + }, + "appInsightsName": { + "type": "string", + "defaultValue": "" + }, + "appServicePlanName": { + "type": "string" + }, + "appServicePlanResourceGroup": { + "type": "string" + }, + "botSku": { + "type": "string", + "defaultValue": "F0", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." + } + } + }, + "variables": { + "siteHost": "[concat(parameters('botName'), '.azurewebsites.net')]", + "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]", + "publishingUsername": "[concat('$', parameters('botName'))]" + }, + "resources": [ + { + "type": "Microsoft.Web/sites", + "apiVersion": "2020-09-01", + "name": "[parameters('botName')]", + "location": "[parameters('botLocation')]", + "kind": "app", + "properties": { + "enabled": true, + "hostNameSslStates": [ + { + "name": "[concat(parameters('botName'), '.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Standard" + }, + { + "name": "[concat(parameters('botName'), '.scm.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Repository" + } + ], + "serverFarmId": "[concat('/subscriptions/', subscription().id,'/resourcegroups/', parameters('appServicePlanResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('appServicePlanName'))]", + "reserved": true, + "hyperV": false, + "siteConfig": { + "appSettings": [ + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "10.14.1" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + }, + { + "name": "APPINSIGHTS_INSTRUMENTATIONKEY", + "value": "[if(empty(parameters('appInsightsName')), '', reference(resourceId(parameters('appServicePlanResourceGroup'),'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01', 'Full').properties.InstrumentationKey)]" + }, + { + "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", + "value": "[if(empty(parameters('appInsightsName')), '', reference(resourceId(parameters('appServicePlanResourceGroup'),'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01', 'Full').properties.ConnectionString)]" + }, + { + "name": "ApplicationInsightsAgent_EXTENSION_VERSION", + "value": "~2" + } + ], + "webSocketsEnabled": true, + "scmType": "None", + "use32BitWorkerProcess": true, + "alwaysOn": true, + "managedPipelineMode": "Integrated", + "virtualApplications": [ + { + "virtualPath": "/", + "physicalPath": "site\\wwwroot", + "preloadEnabled": true + } + ], + "loadBalancing": "LeastRequests", + "experiments": { + "rampUpRules": [] + }, + "autoHealEnabled": false, + "cors": { + "allowedOrigins": [ + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/" + ], + "supportCredentials": false + }, + "localMySqlEnabled": false, + "ipSecurityRestrictions": [ + { + "ipAddress": "Any", + "action": "Allow", + "priority": 1, + "name": "Allow all", + "description": "Allow all access" + } + ], + "scmIpSecurityRestrictions": [ + { + "ipAddress": "Any", + "action": "Allow", + "priority": 1, + "name": "Allow all", + "description": "Allow all access" + } + ], + "scmIpSecurityRestrictionsUseMain": false, + "http20Enabled": false, + "minTlsVersion": "1.2", + "ftpsState": "AllAllowed", + "numberOfWorkers": 1, + "defaultDocuments": [ + "Default.htm", + "Default.html", + "Default.asp", + "index.htm", + "index.html", + "iisstart.htm", + "default.aspx", + "index.php", + "hostingstart.html" + ], + "netFrameworkVersion": "v4.0", + "phpVersion": "5.6", + "requestTracingEnabled": false, + "remoteDebuggingEnabled": false, + "httpLoggingEnabled": true, + "logsDirectorySizeLimit": 35, + "detailedErrorLoggingEnabled": false, + "publishingUsername": "[variables('publishingUsername')]" + }, + "scmSiteAlsoStopped": false, + "clientAffinityEnabled": true, + "hostNamesDisabled": false, + "clientCertEnabled": false, + "httpsOnly": false, + "redundancyMode": "None" + } + }, + { + "type": "Microsoft.Web/sites/hostNameBindings", + "apiVersion": "2020-09-01", + "name": "[concat(parameters('botName'), '/', parameters('botName'), '.azurewebsites.net')]", + "location": "[parameters('botLocation')]", + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('botName'))]" + ], + "properties": { + "siteName": "[parameters('botName')]", + "hostNameType": "Verified" + } + }, + { + "type": "Microsoft.BotService/botServices", + "apiVersion": "2020-06-02", + "name": "[parameters('botName')]", + "location": "global", + "kind": "bot", + "sku": { + "name": "[parameters('botSku')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('botName'))]" + ], + "properties": { + "name": "[parameters('botName')]", + "displayName": "[parameters('botName')]", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "developerAppInsightsApplicationId": "", + "developerAppInsightKey": "", + "publishingCredentials": null, + "storageResourceId": null + } + } + ] +} \ No newline at end of file diff --git a/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml b/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml index d7084aa0ad..ac9e1d857b 100644 --- a/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml +++ b/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml @@ -154,30 +154,57 @@ stages: pathToPublish: "$(SYSTEM.DEFAULTWORKINGDIRECTORY)/${{ parameters.buildFolder }}/${{ bot.name }}/${{ bot.name }}.zip" artifactName: dotnet-$(BUILD.BUILDID) + - ${{ if eq(bot.project.integration, 'webapp') }}: # Create App Service and Bot Channel Registration - - template: ../common/createAppService.yml - parameters: - appId: $(APPID) - appInsight: "${{ parameters.appInsight }}" - appSecret: $(APPSECRET) - appServicePlan: "${{ parameters.appServicePlan }}" - appServicePlanRG: "${{ parameters.appServicePlanRG }}" - azureSubscription: "${{ parameters.azureSubscription }}" - botGroup: "${{ parameters.resourceGroup }}" - botName: "${{ bot.name }}" - botPricingTier: "${{ parameters.botPricingTier }}" - resourceSuffix: "${{ parameters.resourceSuffix }}" - templateFile: "build/templates/template-bot-resources.json" + - template: ../common/createAppService.yml + parameters: + appId: $(APPID) + appInsight: "${{ parameters.appInsight }}" + appSecret: $(APPSECRET) + appServicePlan: "${{ parameters.appServicePlan }}" + appServicePlanRG: "${{ parameters.appServicePlanRG }}" + azureSubscription: "${{ parameters.azureSubscription }}" + botGroup: "${{ parameters.resourceGroup }}" + botName: "${{ bot.name }}" + botPricingTier: "${{ parameters.botPricingTier }}" + resourceSuffix: "${{ parameters.resourceSuffix }}" + templateFile: "build/templates/template-bot-resources.json" - # Deploy bot - - task: AzureWebApp@1 - displayName: 'Deploy Azure Web App : ${{ bot.name }}-$(BUILD.BUILDID)' - inputs: - azureSubscription: "${{ parameters.azureSubscription }}" - appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' - resourceGroupName: '${{ parameters.resourceGroup }}' - package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/${{ parameters.buildFolder }}/${{ bot.name }}/${{ bot.name }}.zip' - deploymentMethod: runFromPackage + # Deploy bot to Azure Web App + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : ${{ bot.name }}-$(BUILD.BUILDID)' + inputs: + azureSubscription: "${{ parameters.azureSubscription }}" + appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' + resourceGroupName: '${{ parameters.resourceGroup }}' + package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/${{ parameters.buildFolder }}/${{ bot.name }}/${{ bot.name }}.zip' + deploymentMethod: runFromPackage + + - ${{ if eq(bot.project.integration, 'functions') }}: + # Create Functions App and Bot Channel Registration + - template: ../common/createAppService.yml + parameters: + appId: $(APPID) + appInsight: "${{ parameters.appInsight }}" + appSecret: $(APPSECRET) + appServicePlan: "${{ parameters.appServicePlan }}" + appServicePlanRG: "${{ parameters.appServicePlanRG }}" + azureSubscription: "${{ parameters.azureSubscription }}" + botGroup: "${{ parameters.resourceGroup }}" + botName: "${{ bot.name }}" + botPricingTier: "${{ parameters.botPricingTier }}" + resourceSuffix: "${{ parameters.resourceSuffix }}" + templateFile: "build/templates/template-function-bot-resources.json" + + # Deploy bot to Azure Web App + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : ${{ bot.name }}-$(BUILD.BUILDID)' + inputs: + azureSubscription: "${{ parameters.azureSubscription }}" + appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' + resourceGroupName: '${{ parameters.resourceGroup }}' + package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/${{ parameters.buildFolder }}/${{ bot.name }}/${{ bot.name }}.zip' + deploymentMethod: runFromPackage # Configure OAuth - ${{ if eq(bot.type, 'Skill') }}: From f66a0c4db01d35d64a2e48797de04e936ff16d95 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 12:00:33 -0700 Subject: [PATCH 2/8] Import functions ARM tempalte from composer and test deploying to it --- .../template-function-bot-resources.json | 144 +++--------------- .../yaml/deployBotResources/dotnet/deploy.yml | 8 +- 2 files changed, 28 insertions(+), 124 deletions(-) diff --git a/build/templates/template-function-bot-resources.json b/build/templates/template-function-bot-resources.json index de5faada36..a18025dd36 100644 --- a/build/templates/template-function-bot-resources.json +++ b/build/templates/template-function-bot-resources.json @@ -46,129 +46,33 @@ "resources": [ { "type": "Microsoft.Web/sites", - "apiVersion": "2020-09-01", - "name": "[parameters('botName')]", + "apiVersion": "2015-08-01", "location": "[parameters('botLocation')]", - "kind": "app", + "kind": "functionapp", + "name": "[parameters('botName')]", "properties": { - "enabled": true, - "hostNameSslStates": [ - { - "name": "[concat(parameters('botName'), '.azurewebsites.net')]", - "sslState": "Disabled", - "hostType": "Standard" - }, - { - "name": "[concat(parameters('botName'), '.scm.azurewebsites.net')]", - "sslState": "Disabled", - "hostType": "Repository" - } - ], - "serverFarmId": "[concat('/subscriptions/', subscription().id,'/resourcegroups/', parameters('appServicePlanResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('appServicePlanName'))]", - "reserved": true, - "hyperV": false, - "siteConfig": { - "appSettings": [ - { - "name": "WEBSITE_NODE_DEFAULT_VERSION", - "value": "10.14.1" - }, - { - "name": "MicrosoftAppId", - "value": "[parameters('appId')]" - }, - { - "name": "MicrosoftAppPassword", - "value": "[parameters('appSecret')]" - }, - { - "name": "APPINSIGHTS_INSTRUMENTATIONKEY", - "value": "[if(empty(parameters('appInsightsName')), '', reference(resourceId(parameters('appServicePlanResourceGroup'),'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01', 'Full').properties.InstrumentationKey)]" - }, - { - "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[if(empty(parameters('appInsightsName')), '', reference(resourceId(parameters('appServicePlanResourceGroup'),'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01', 'Full').properties.ConnectionString)]" - }, - { - "name": "ApplicationInsightsAgent_EXTENSION_VERSION", - "value": "~2" - } - ], - "webSocketsEnabled": true, - "scmType": "None", - "use32BitWorkerProcess": true, - "alwaysOn": true, - "managedPipelineMode": "Integrated", - "virtualApplications": [ - { - "virtualPath": "/", - "physicalPath": "site\\wwwroot", - "preloadEnabled": true - } - ], - "loadBalancing": "LeastRequests", - "experiments": { - "rampUpRules": [] - }, - "autoHealEnabled": false, - "cors": { - "allowedOrigins": [ - "https://botservice.hosting.portal.azure.net", - "https://hosting.onecloud.azure-test.net/" - ], - "supportCredentials": false - }, - "localMySqlEnabled": false, - "ipSecurityRestrictions": [ - { - "ipAddress": "Any", - "action": "Allow", - "priority": 1, - "name": "Allow all", - "description": "Allow all access" - } - ], - "scmIpSecurityRestrictions": [ - { - "ipAddress": "Any", - "action": "Allow", - "priority": 1, - "name": "Allow all", - "description": "Allow all access" - } - ], - "scmIpSecurityRestrictionsUseMain": false, - "http20Enabled": false, - "minTlsVersion": "1.2", - "ftpsState": "AllAllowed", - "numberOfWorkers": 1, - "defaultDocuments": [ - "Default.htm", - "Default.html", - "Default.asp", - "index.htm", - "index.html", - "iisstart.htm", - "default.aspx", - "index.php", - "hostingstart.html" + "name": "[parameters('botName')]", + "kind": "functionapp", + "httpsOnly": true, + "alwaysOn": true + }, + "resources": [ + { + "name": "appsettings", + "type": "config", + "apiVersion": "2015-08-01", + "dependsOn": [ + "[concat('Microsoft.Web/Sites/', parameters('botName'))]" ], - "netFrameworkVersion": "v4.0", - "phpVersion": "5.6", - "requestTracingEnabled": false, - "remoteDebuggingEnabled": false, - "httpLoggingEnabled": true, - "logsDirectorySizeLimit": 35, - "detailedErrorLoggingEnabled": false, - "publishingUsername": "[variables('publishingUsername')]" - }, - "scmSiteAlsoStopped": false, - "clientAffinityEnabled": true, - "hostNamesDisabled": false, - "clientCertEnabled": false, - "httpsOnly": false, - "redundancyMode": "None" - } + "properties": { + "FUNCTIONS_EXTENSION_VERSION": "~3", + "FUNCTIONS_WORKER_RUNTIME": "dotnet", + "APPINSIGHTS_INSTRUMENTATIONKEY": "[if(empty(parameters('appInsightsName')), '', reference(resourceId(parameters('appServicePlanResourceGroup'),'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01', 'Full').properties.InstrumentationKey)]", + "MicrosoftAppId": "[parameters('appId')]", + "MicrosoftAppPassword": "[parameters('appSecret')]" + } + } + ] }, { "type": "Microsoft.Web/sites/hostNameBindings", diff --git a/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml b/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml index ac9e1d857b..aa7ade238a 100644 --- a/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml +++ b/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml @@ -196,13 +196,13 @@ stages: resourceSuffix: "${{ parameters.resourceSuffix }}" templateFile: "build/templates/template-function-bot-resources.json" - # Deploy bot to Azure Web App - - task: AzureWebApp@1 - displayName: 'Deploy Azure Web App : ${{ bot.name }}-$(BUILD.BUILDID)' + # Deploy bot to Azure Functions + - task: AzureFunctionApp@1 + displayName: 'Deploy Functions App : ${{ bot.name }}-$(BUILD.BUILDID)' inputs: azureSubscription: "${{ parameters.azureSubscription }}" + appType: 'functionApp' appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' - resourceGroupName: '${{ parameters.resourceGroup }}' package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/${{ parameters.buildFolder }}/${{ bot.name }}/${{ bot.name }}.zip' deploymentMethod: runFromPackage From a3ae3f10481bc987d6ababb2a8c19c8129b96cf5 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 13:06:54 -0700 Subject: [PATCH 3/8] add shared service farm to function app --- build/templates/template-function-bot-resources.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/templates/template-function-bot-resources.json b/build/templates/template-function-bot-resources.json index a18025dd36..b14723a440 100644 --- a/build/templates/template-function-bot-resources.json +++ b/build/templates/template-function-bot-resources.json @@ -54,7 +54,8 @@ "name": "[parameters('botName')]", "kind": "functionapp", "httpsOnly": true, - "alwaysOn": true + "alwaysOn": true, + "serverFarmId": "[concat('/subscriptions/', subscription().id,'/resourcegroups/', parameters('appServicePlanResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('appServicePlanName'))]" }, "resources": [ { From 3151cb01fcfc60f5bd42d7af4684b23d52869a8d Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 14:18:17 -0700 Subject: [PATCH 4/8] add fnctions steps to js deploy --- .../yaml/deployBotResources/js/deploy.yml | 71 +++++++++++++------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/tests/functional/build/yaml/deployBotResources/js/deploy.yml b/tests/functional/build/yaml/deployBotResources/js/deploy.yml index a8994dc8b8..2d468b040d 100644 --- a/tests/functional/build/yaml/deployBotResources/js/deploy.yml +++ b/tests/functional/build/yaml/deployBotResources/js/deploy.yml @@ -172,30 +172,57 @@ stages: pathToPublish: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}.zip' artifactName: javascript-$(BUILD.BUILDID) + - ${{ if eq(bot.project.integration, 'webapp') }}: # Create App Service and Bot Channel Registration - - template: ../common/createAppService.yml - parameters: - appId: $(APPID) - appInsight: "${{ parameters.appInsight }}" - appSecret: $(APPSECRET) - appServicePlan: "${{ parameters.appServicePlan }}" - appServicePlanRG: "${{ parameters.appServicePlanRG }}" - azureSubscription: "${{ parameters.azureSubscription }}" - botGroup: "${{ parameters.resourceGroup }}" - botName: "${{ bot.name }}" - botPricingTier: "${{ parameters.botPricingTier }}" - resourceSuffix: "${{ parameters.resourceSuffix }}" - templateFile: "build/templates/template-bot-resources.json" + - template: ../common/createAppService.yml + parameters: + appId: $(APPID) + appInsight: "${{ parameters.appInsight }}" + appSecret: $(APPSECRET) + appServicePlan: "${{ parameters.appServicePlan }}" + appServicePlanRG: "${{ parameters.appServicePlanRG }}" + azureSubscription: "${{ parameters.azureSubscription }}" + botGroup: "${{ parameters.resourceGroup }}" + botName: "${{ bot.name }}" + botPricingTier: "${{ parameters.botPricingTier }}" + resourceSuffix: "${{ parameters.resourceSuffix }}" + templateFile: "build/templates/template-bot-resources.json" - # Deploy bot - - task: AzureWebApp@1 - displayName: 'Deploy Azure Web App : ${{ bot.name }}-$(BUILD.BUILDID)' - inputs: - azureSubscription: "${{ parameters.azureSubscription }}" - appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' - resourceGroupName: '${{ parameters.resourceGroup }}' - package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}.zip' - deploymentMethod: runFromPackage + # Deploy bot to Azure Web App + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : ${{ bot.name }}-$(BUILD.BUILDID)' + inputs: + azureSubscription: "${{ parameters.azureSubscription }}" + appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' + resourceGroupName: '${{ parameters.resourceGroup }}' + package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}/${{ bot.name }}.zip' + deploymentMethod: runFromPackage + + - ${{ if eq(bot.project.integration, 'functions') }}: + # Create Functions App and Bot Channel Registration + - template: ../common/createAppService.yml + parameters: + appId: $(APPID) + appInsight: "${{ parameters.appInsight }}" + appSecret: $(APPSECRET) + appServicePlan: "${{ parameters.appServicePlan }}" + appServicePlanRG: "${{ parameters.appServicePlanRG }}" + azureSubscription: "${{ parameters.azureSubscription }}" + botGroup: "${{ parameters.resourceGroup }}" + botName: "${{ bot.name }}" + botPricingTier: "${{ parameters.botPricingTier }}" + resourceSuffix: "${{ parameters.resourceSuffix }}" + templateFile: "build/templates/template-function-bot-resources.json" + + # Deploy bot to Azure Functions + - task: AzureFunctionApp@1 + displayName: 'Deploy Functions App : ${{ bot.name }}-$(BUILD.BUILDID)' + inputs: + azureSubscription: "${{ parameters.azureSubscription }}" + appType: 'functionApp' + appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' + package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}/${{ bot.name }}.zip' + deploymentMethod: runFromPackage # Configure OAuth - ${{ if eq(bot.type, 'Skill') }}: From a4deb7adf773055820c94d405b47f871f2838e2c Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 15:31:51 -0700 Subject: [PATCH 5/8] revert shared serverfarm and fix js build directory --- build/templates/template-function-bot-resources.json | 3 +-- tests/functional/build/yaml/deployBotResources/js/deploy.yml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build/templates/template-function-bot-resources.json b/build/templates/template-function-bot-resources.json index b14723a440..a18025dd36 100644 --- a/build/templates/template-function-bot-resources.json +++ b/build/templates/template-function-bot-resources.json @@ -54,8 +54,7 @@ "name": "[parameters('botName')]", "kind": "functionapp", "httpsOnly": true, - "alwaysOn": true, - "serverFarmId": "[concat('/subscriptions/', subscription().id,'/resourcegroups/', parameters('appServicePlanResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('appServicePlanName'))]" + "alwaysOn": true }, "resources": [ { diff --git a/tests/functional/build/yaml/deployBotResources/js/deploy.yml b/tests/functional/build/yaml/deployBotResources/js/deploy.yml index 2d468b040d..c28261df41 100644 --- a/tests/functional/build/yaml/deployBotResources/js/deploy.yml +++ b/tests/functional/build/yaml/deployBotResources/js/deploy.yml @@ -195,7 +195,7 @@ stages: azureSubscription: "${{ parameters.azureSubscription }}" appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' resourceGroupName: '${{ parameters.resourceGroup }}' - package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}/${{ bot.name }}.zip' + package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}.zip' deploymentMethod: runFromPackage - ${{ if eq(bot.project.integration, 'functions') }}: @@ -221,7 +221,7 @@ stages: azureSubscription: "${{ parameters.azureSubscription }}" appType: 'functionApp' appName: '${{ bot.name }}${{ parameters.resourceSuffix }}-$(BUILD.BUILDID)' - package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}/${{ bot.name }}.zip' + package: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/build/${{ bot.name }}.zip' deploymentMethod: runFromPackage # Configure OAuth From ba1b77e00a041f7a80bf97a3e50f3bfd0d1c21da Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 16:53:19 -0700 Subject: [PATCH 6/8] separate dotnet/js function arm deployment templates --- ...mplate-function-dotnet-bot-resources.json} | 3 +- .../template-function-js-bot-resources.json | 116 ++++++++++++++++++ .../yaml/deployBotResources/dotnet/deploy.yml | 2 +- .../yaml/deployBotResources/js/deploy.yml | 2 +- 4 files changed, 120 insertions(+), 3 deletions(-) rename build/templates/{template-function-bot-resources.json => template-function-dotnet-bot-resources.json} (98%) create mode 100644 build/templates/template-function-js-bot-resources.json diff --git a/build/templates/template-function-bot-resources.json b/build/templates/template-function-dotnet-bot-resources.json similarity index 98% rename from build/templates/template-function-bot-resources.json rename to build/templates/template-function-dotnet-bot-resources.json index a18025dd36..4d8ee5aeaf 100644 --- a/build/templates/template-function-bot-resources.json +++ b/build/templates/template-function-dotnet-bot-resources.json @@ -54,7 +54,8 @@ "name": "[parameters('botName')]", "kind": "functionapp", "httpsOnly": true, - "alwaysOn": true + "alwaysOn": true, + "webSocketsEnabled": true }, "resources": [ { diff --git a/build/templates/template-function-js-bot-resources.json b/build/templates/template-function-js-bot-resources.json new file mode 100644 index 0000000000..03c4145641 --- /dev/null +++ b/build/templates/template-function-js-bot-resources.json @@ -0,0 +1,116 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings." + } + }, + "botName": { + "type": "string" + }, + "botLocation": { + "type": "string" + }, + "appInsightsName": { + "type": "string", + "defaultValue": "" + }, + "appServicePlanName": { + "type": "string" + }, + "appServicePlanResourceGroup": { + "type": "string" + }, + "botSku": { + "type": "string", + "defaultValue": "F0", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." + } + } + }, + "variables": { + "siteHost": "[concat(parameters('botName'), '.azurewebsites.net')]", + "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]", + "publishingUsername": "[concat('$', parameters('botName'))]" + }, + "resources": [ + { + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "location": "[parameters('botLocation')]", + "kind": "functionapp", + "name": "[parameters('botName')]", + "properties": { + "name": "[parameters('botName')]", + "kind": "functionapp", + "httpsOnly": true, + "alwaysOn": true, + "webSocketsEnabled": true + }, + "resources": [ + { + "name": "appsettings", + "type": "config", + "apiVersion": "2015-08-01", + "dependsOn": [ + "[concat('Microsoft.Web/Sites/', parameters('botName'))]" + ], + "properties": { + "FUNCTIONS_EXTENSION_VERSION": "~3", + "FUNCTIONS_WORKER_RUNTIME": "node", + "WEBSITE_NODE_DEFAULT_VERSION": "~14", + "APPINSIGHTS_INSTRUMENTATIONKEY": "[if(empty(parameters('appInsightsName')), '', reference(resourceId(parameters('appServicePlanResourceGroup'),'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01', 'Full').properties.InstrumentationKey)]", + "MicrosoftAppId": "[parameters('appId')]", + "MicrosoftAppPassword": "[parameters('appSecret')]" + } + } + ] + }, + { + "type": "Microsoft.Web/sites/hostNameBindings", + "apiVersion": "2020-09-01", + "name": "[concat(parameters('botName'), '/', parameters('botName'), '.azurewebsites.net')]", + "location": "[parameters('botLocation')]", + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('botName'))]" + ], + "properties": { + "siteName": "[parameters('botName')]", + "hostNameType": "Verified" + } + }, + { + "type": "Microsoft.BotService/botServices", + "apiVersion": "2020-06-02", + "name": "[parameters('botName')]", + "location": "global", + "kind": "bot", + "sku": { + "name": "[parameters('botSku')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('botName'))]" + ], + "properties": { + "name": "[parameters('botName')]", + "displayName": "[parameters('botName')]", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "developerAppInsightsApplicationId": "", + "developerAppInsightKey": "", + "publishingCredentials": null, + "storageResourceId": null + } + } + ] +} \ No newline at end of file diff --git a/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml b/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml index aa7ade238a..8f03969b23 100644 --- a/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml +++ b/tests/functional/build/yaml/deployBotResources/dotnet/deploy.yml @@ -194,7 +194,7 @@ stages: botName: "${{ bot.name }}" botPricingTier: "${{ parameters.botPricingTier }}" resourceSuffix: "${{ parameters.resourceSuffix }}" - templateFile: "build/templates/template-function-bot-resources.json" + templateFile: "build/templates/template-function-dotnet-bot-resources.json" # Deploy bot to Azure Functions - task: AzureFunctionApp@1 diff --git a/tests/functional/build/yaml/deployBotResources/js/deploy.yml b/tests/functional/build/yaml/deployBotResources/js/deploy.yml index c28261df41..ff5ea602a7 100644 --- a/tests/functional/build/yaml/deployBotResources/js/deploy.yml +++ b/tests/functional/build/yaml/deployBotResources/js/deploy.yml @@ -212,7 +212,7 @@ stages: botName: "${{ bot.name }}" botPricingTier: "${{ parameters.botPricingTier }}" resourceSuffix: "${{ parameters.resourceSuffix }}" - templateFile: "build/templates/template-function-bot-resources.json" + templateFile: "build/templates/template-function-js-bot-resources.json" # Deploy bot to Azure Functions - task: AzureFunctionApp@1 From a3a1c23380e220b44c0777234187fb0d7322adfc Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Tue, 13 Jul 2021 19:03:49 -0700 Subject: [PATCH 7/8] Add functions bots to test scenarios --- .../Common/HostBot.cs | 12 +++++++++++- .../EmptyBot/EmptyBotTests.cs | 4 +++- .../ComponentsFunctionalTests/appsettings.json | 8 ++++++++ .../yaml/testScenarios/configureConsumers.yml | 18 +++++++++++++++++- .../yaml/testScenarios/runTestScenarios.yml | 6 +++++- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/tests/functional/Tests/ComponentsFunctionalTests/Common/HostBot.cs b/tests/functional/Tests/ComponentsFunctionalTests/Common/HostBot.cs index 9d18a41068..8412fa936f 100644 --- a/tests/functional/Tests/ComponentsFunctionalTests/Common/HostBot.cs +++ b/tests/functional/Tests/ComponentsFunctionalTests/Common/HostBot.cs @@ -10,9 +10,19 @@ public enum HostBot /// EmptyBotDotNetWebApp, + /// + /// Empty bot implemented using DotNet and Functions. + /// + EmptyBotDotNetFunctions, + /// /// Empty bot implemented using JS and Web App. /// - EmptyBotJSWebApp + EmptyBotJSWebApp, + + /// + /// Empty bot implemented using JS and Functions. + /// + EmptyBotJSFunctions } } diff --git a/tests/functional/Tests/ComponentsFunctionalTests/EmptyBot/EmptyBotTests.cs b/tests/functional/Tests/ComponentsFunctionalTests/EmptyBot/EmptyBotTests.cs index 5eaeae0a2a..883a4dbdc3 100644 --- a/tests/functional/Tests/ComponentsFunctionalTests/EmptyBot/EmptyBotTests.cs +++ b/tests/functional/Tests/ComponentsFunctionalTests/EmptyBot/EmptyBotTests.cs @@ -37,7 +37,9 @@ public static IEnumerable TestCases() var hostBots = new List { HostBot.EmptyBotDotNetWebApp, - HostBot.EmptyBotJSWebApp + HostBot.EmptyBotDotNetFunctions, + HostBot.EmptyBotJSWebApp, + HostBot.EmptyBotJSFunctions }; var scripts = new List { "EmptyBot.json" }; diff --git a/tests/functional/Tests/ComponentsFunctionalTests/appsettings.json b/tests/functional/Tests/ComponentsFunctionalTests/appsettings.json index af1a042508..ff4b218749 100644 --- a/tests/functional/Tests/ComponentsFunctionalTests/appsettings.json +++ b/tests/functional/Tests/ComponentsFunctionalTests/appsettings.json @@ -13,9 +13,17 @@ "BotId": "bfcfnemptybotdotnetwebapp", "DirectLineSecret": "" }, + "EmptyBotDotNetFunctions": { + "BotId": "bfcfnemptybotdotnetfunctions", + "DirectLineSecret": "" + }, "EmptyBotJSWebApp": { "BotId": "bfcfnemptybotjswebapp", "DirectLineSecret": "" + }, + "EmptyBotJSFunctions": { + "BotId": "bfcfnemptybotjsfunctions", + "DirectLineSecret": "" } } } diff --git a/tests/functional/build/yaml/testScenarios/configureConsumers.yml b/tests/functional/build/yaml/testScenarios/configureConsumers.yml index c6100be4fe..3e9678a85a 100644 --- a/tests/functional/build/yaml/testScenarios/configureConsumers.yml +++ b/tests/functional/build/yaml/testScenarios/configureConsumers.yml @@ -4,7 +4,9 @@ parameters: type: object default: EmptyBotDotNetWebApp: "" + EmptyBotDotNetFunctions: "" EmptyBotJSWebApp: "" + EmptyBotJSFunctions: "" - name: azureSubscription displayName: Azure Service Connection @@ -401,12 +403,24 @@ steps: resourceGroup = $groups.DotNet configType = $types.Appsettings } + @{ + key = "EmptyBotDotNetFunctions" + botName = "bfcfnemptybotdotnetfunctions" + resourceGroup = $groups.DotNet + configType = $types.Appsettings + } @{ key = "EmptyBotJSWebApp" botName = "bfcfnemptybotjswebapp" resourceGroup = $groups.JS configType = $types.Appsettings } + @{ + key = "EmptyBotJSFunctions" + botName = "bfcfnemptybotjsfunctions" + resourceGroup = $groups.JS + configType = $types.Appsettings + } ) # Bots Test Scenarios @@ -415,7 +429,9 @@ steps: name = "EmptyBot"; consumers = @( "EmptyBotDotNetWebApp", - "EmptyBotJSWebApp" + "EmptyBotJSFunctions", + "EmptyBotJSWebApp", + "EmptyBotJSFunctions" ); } ) diff --git a/tests/functional/build/yaml/testScenarios/runTestScenarios.yml b/tests/functional/build/yaml/testScenarios/runTestScenarios.yml index 9f947008bd..c3fe9839e2 100644 --- a/tests/functional/build/yaml/testScenarios/runTestScenarios.yml +++ b/tests/functional/build/yaml/testScenarios/runTestScenarios.yml @@ -17,7 +17,9 @@ variables: ## Bots Configuration (Define these variables in Azure) # BfcfnEmptyBotDotNetWebAppId: (optional) App Id for BfcfnEmptyBotDotNetWebApp bot. - # BfcfnEmptyBotJSWebAppAppId: (optional) App Id for BfcfnEmptyBotJSWebApp bot. + # BfcfnEmptyBotDotNetFunctionsId: (optional) App Id for BfcfnEmptyBotDotNetFunctions bot. + # BfcfnEmptyBotJSWebAppId: (optional) App Id for BfcfnEmptyBotJSWebApp bot. + # BfcfnEmptyBotJSFunctionsId: (optional) App Id for BfcfnEmptyBotJSFunctions bot. # DeployBotResourcesGuid: (optional) Deploy Bot Resources pipeline GUID. @@ -64,7 +66,9 @@ stages: parameters: appIds: EmptyBotDotNetWebApp: "$(BFCFNEMPTYBOTDOTNETWEBAPPID)" + EmptyBotDotNetFunctions: "$(BFCFNEMPTYBOTDOTNETFUNCTIONSID)" EmptyBotJSWebApp: "$(BFCFNEMPTYBOTJSWEBAPPID)" + EmptyBotJSFunctions: "$(BFCFNEMPTYBOTJSFUNCTIONSID)" azureSubscription: "$(AZURESUBSCRIPTION)" buildConfiguration: "$(BUILDCONFIGURATION)" buildIdSuffix: $[stageDependencies.Download_Variables.Download_Variables.outputs['Set_Variables.DeploymentBuildSuffix']] From 034e8081a994501715ccc20da4134604918200dd Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Wed, 14 Jul 2021 10:04:34 -0700 Subject: [PATCH 8/8] Fix ref for DotNetFunctions consumer --- .../functional/build/yaml/testScenarios/configureConsumers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/build/yaml/testScenarios/configureConsumers.yml b/tests/functional/build/yaml/testScenarios/configureConsumers.yml index 3e9678a85a..df53957890 100644 --- a/tests/functional/build/yaml/testScenarios/configureConsumers.yml +++ b/tests/functional/build/yaml/testScenarios/configureConsumers.yml @@ -429,7 +429,7 @@ steps: name = "EmptyBot"; consumers = @( "EmptyBotDotNetWebApp", - "EmptyBotJSFunctions", + "EmptyBotDotNetFunctions", "EmptyBotJSWebApp", "EmptyBotJSFunctions" );