-
Notifications
You must be signed in to change notification settings - Fork 304
Add ARM template to flask core-bot #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e11acb
add initial functioning ARM template for flask core-bot
stevengum 796f459
fix conflict in config.py
stevengum c2b9298
rename ARM template in flask core-bot
stevengum 8f4a98d
add back docstring in config.py for flask core-bot
stevengum 8d9bf3e
Merge branch 'master' into stgum/arm-template
stevengum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
242 changes: 242 additions & 0 deletions
242
samples/python-flask/13.core-bot/deploymentTemplates/template-with-preexisting-rg.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,242 @@ | ||
| { | ||
| "$schema": "https://schema.management.azure.com/schemas/2015-01-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." | ||
| } | ||
| }, | ||
| "botId": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable." | ||
| } | ||
| }, | ||
| "botSku": { | ||
| "defaultValue": "F0", | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." | ||
| } | ||
| }, | ||
| "newAppServicePlanName": { | ||
| "type": "string", | ||
| "defaultValue": "", | ||
| "metadata": { | ||
| "description": "The name of the new App Service Plan." | ||
| } | ||
| }, | ||
| "newAppServicePlanSku": { | ||
| "type": "object", | ||
| "defaultValue": { | ||
| "name": "S1", | ||
| "tier": "Standard", | ||
| "size": "S1", | ||
| "family": "S", | ||
| "capacity": 1 | ||
| }, | ||
| "metadata": { | ||
| "description": "The SKU of the App Service Plan. Defaults to Standard values." | ||
| } | ||
| }, | ||
| "appServicePlanLocation": { | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The location of the App Service Plan." | ||
| } | ||
| }, | ||
| "existingAppServicePlan": { | ||
| "type": "string", | ||
| "defaultValue": "", | ||
| "metadata": { | ||
| "description": "Name of the existing App Service Plan used to create the Web App for the bot." | ||
| } | ||
| }, | ||
| "newWebAppName": { | ||
| "type": "string", | ||
| "defaultValue": "", | ||
| "metadata": { | ||
| "description": "The globally unique name of the Web App. Defaults to the value passed in for \"botId\"." | ||
| } | ||
| } | ||
| }, | ||
| "variables": { | ||
| "defaultAppServicePlanName": "[if(empty(parameters('existingAppServicePlan')), 'createNewAppServicePlan', parameters('existingAppServicePlan'))]", | ||
| "useExistingAppServicePlan": "[not(equals(variables('defaultAppServicePlanName'), 'createNewAppServicePlan'))]", | ||
| "servicePlanName": "[if(variables('useExistingAppServicePlan'), parameters('existingAppServicePlan'), parameters('newAppServicePlanName'))]", | ||
| "publishingUsername": "[concat('$', parameters('newWebAppName'))]", | ||
| "resourcesLocation": "[parameters('appServicePlanLocation')]", | ||
| "webAppName": "[if(empty(parameters('newWebAppName')), parameters('botId'), parameters('newWebAppName'))]", | ||
| "siteHost": "[concat(variables('webAppName'), '.azurewebsites.net')]", | ||
| "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]" | ||
| }, | ||
| "resources": [ | ||
| { | ||
| "comments": "Create a new Linux App Service Plan if no existing App Service Plan name was passed in.", | ||
| "type": "Microsoft.Web/serverfarms", | ||
| "apiVersion": "2016-09-01", | ||
| "name": "[variables('servicePlanName')]", | ||
| "location": "[variables('resourcesLocation')]", | ||
| "sku": "[parameters('newAppServicePlanSku')]", | ||
| "kind": "linux", | ||
| "properties": { | ||
| "name": "[variables('servicePlanName')]", | ||
| "perSiteScaling": false, | ||
| "reserved": true, | ||
| "targetWorkerCount": 0, | ||
| "targetWorkerSizeId": 0 | ||
| } | ||
| }, | ||
| { | ||
| "comments": "Create a Web App using a Linux App Service Plan", | ||
| "type": "Microsoft.Web/sites", | ||
| "apiVersion": "2016-08-01", | ||
| "name": "[variables('webAppName')]", | ||
| "location": "[variables('resourcesLocation')]", | ||
| "dependsOn": [ | ||
| "[resourceId('Microsoft.Web/serverfarms/', variables('servicePlanName'))]" | ||
| ], | ||
| "kind": "app,linux", | ||
| "properties": { | ||
| "enabled": true, | ||
| "hostNameSslStates": [ | ||
| { | ||
| "name": "[concat(parameters('newWebAppName'), '.azurewebsites.net')]", | ||
| "sslState": "Disabled", | ||
| "hostType": "Standard" | ||
| }, | ||
| { | ||
| "name": "[concat(parameters('newWebAppName'), '.scm.azurewebsites.net')]", | ||
| "sslState": "Disabled", | ||
| "hostType": "Repository" | ||
| } | ||
| ], | ||
| "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]", | ||
| "reserved": true, | ||
| "scmSiteAlsoStopped": false, | ||
| "clientAffinityEnabled": false, | ||
| "clientCertEnabled": false, | ||
| "hostNamesDisabled": false, | ||
| "containerSize": 0, | ||
| "dailyMemoryTimeQuota": 0, | ||
| "httpsOnly": false, | ||
| "siteConfig": { | ||
| "appSettings": [ | ||
| { | ||
| "name": "MicrosoftAppId", | ||
| "value": "[parameters('appId')]" | ||
| }, | ||
| { | ||
| "name": "MicrosoftAppPassword", | ||
| "value": "[parameters('appSecret')]" | ||
| }, | ||
| { | ||
| "name": "SCM_DO_BUILD_DURING_DEPLOYMENT", | ||
| "value": "true" | ||
| } | ||
| ], | ||
| "cors": { | ||
| "allowedOrigins": [ | ||
| "https://botservice.hosting.portal.azure.net", | ||
| "https://hosting.onecloud.azure-test.net/" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "type": "Microsoft.Web/sites/config", | ||
| "apiVersion": "2016-08-01", | ||
| "name": "[concat(variables('webAppName'), '/web')]", | ||
| "location": "[variables('resourcesLocation')]", | ||
| "dependsOn": [ | ||
| "[resourceId('Microsoft.Web/sites', variables('webAppName'))]" | ||
| ], | ||
| "properties": { | ||
| "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": "", | ||
| "pythonVersion": "", | ||
| "nodeVersion": "", | ||
| "linuxFxVersion": "PYTHON|3.7", | ||
| "requestTracingEnabled": false, | ||
| "remoteDebuggingEnabled": false, | ||
| "remoteDebuggingVersion": "VS2017", | ||
| "httpLoggingEnabled": true, | ||
| "logsDirectorySizeLimit": 35, | ||
| "detailedErrorLoggingEnabled": false, | ||
| "publishingUsername": "[variables('publishingUsername')]", | ||
| "scmType": "None", | ||
| "use32BitWorkerProcess": true, | ||
| "webSocketsEnabled": false, | ||
| "alwaysOn": false, | ||
| "appCommandLine": "", | ||
| "managedPipelineMode": "Integrated", | ||
| "virtualApplications": [ | ||
| { | ||
| "virtualPath": "/", | ||
| "physicalPath": "site\\wwwroot", | ||
| "preloadEnabled": false, | ||
| "virtualDirectories": null | ||
| } | ||
| ], | ||
| "winAuthAdminState": 0, | ||
| "winAuthTenantState": 0, | ||
| "customAppPoolIdentityAdminState": false, | ||
| "customAppPoolIdentityTenantState": false, | ||
| "loadBalancing": "LeastRequests", | ||
| "routingRules": [], | ||
| "experiments": { | ||
| "rampUpRules": [] | ||
| }, | ||
| "autoHealEnabled": false, | ||
| "vnetName": "", | ||
| "minTlsVersion": "1.2", | ||
| "ftpsState": "AllAllowed", | ||
| "reservedInstanceCount": 0 | ||
| } | ||
| }, | ||
| { | ||
| "apiVersion": "2017-12-01", | ||
| "type": "Microsoft.BotService/botServices", | ||
| "name": "[parameters('botId')]", | ||
| "location": "global", | ||
| "kind": "bot", | ||
| "sku": { | ||
| "name": "[parameters('botSku')]" | ||
| }, | ||
| "properties": { | ||
| "name": "[parameters('botId')]", | ||
| "displayName": "[parameters('botId')]", | ||
| "endpoint": "[variables('botEndpoint')]", | ||
| "msaAppId": "[parameters('appId')]", | ||
| "developerAppInsightsApplicationId": null, | ||
| "developerAppInsightKey": null, | ||
| "publishingCredentials": null, | ||
| "storageResourceId": null | ||
| }, | ||
| "dependsOn": [ | ||
| "[resourceId('Microsoft.Web/sites/', variables('webAppName'))]" | ||
| ] | ||
| } | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious if you've seen this convention documented before? This seems to be combining configuration from files, with environment variables (and the environment variables don't appear to match the casing or spelling of the variables you reference in the code).
When we initially were discussing this earlier, these were referenced as convention for Python :
They do provide examples of environment variables, but don't appear to do indirection through the config object, just directly read into variables.
@axelsrz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the reason I went went the variable keys above is because that's what we use when we provision bots on Azure. We can change the keys right now because we will be using Linux Web Apps instead of Windows Web Apps, but these are the keys we've used across C# and JS to use only one ARM template.
After some preliminary explorations and discussions, I think that the pattern I used above is the simplest way to get a local Python Flask sample bot deployed and running on Azure.
It populates the config with default values, but when deployed to a Linux App Service with the properly configured Application Settings, it reads the environment variables and so the code is ready to use in production.