Search code examples
azurebotframeworkazure-resource-managerazure-qna-maker

Is there any way to completely automate QnAMaker based Azure Bot with ARM template


I am looking for a solution where i should be able to create and configure Azure Bot completely with help of ARM template (It should include creating resources, KB & Web App bot)

  • I have ARM template that create/automate required Cognitive Service, App Service, App insight and Search service on portal
  • The created Services are properly configured and all the app settings are dynamic with correct reference.
  • The next step is it should allow to create Knowledgebase through some automated script (PowerShell preferably) within the same execution, though there is script available to create KB but i am not sure how we can get latest created OCP APIM key and use it for creating knowledge base.

My Question is:

Is there any way we can completely automate

  1. Resource Creation
  2. Knowledgebase creation
  3. Creating Web App Bot

Within single automation script as they are inter dependent (KB on Services, Web App Bot on KB) i hardly found relevant article to achieve this.

Thank you.


Solution

  • Create a KB using the QnAMaker service deployed via ARM. Our ready ARM Templates are available here: https://github.com/Azure/azure-quickstart-templates. Below the endpoint keys are inserted in app config of the qna maker app service.

    {
                "type": "Microsoft.Web/sites",
                "apiVersion": "2016-08-01",
                "name": "[variables('qnaMakerWebName')]",
                "location": "[resourceGroup().location]",
                "properties": {
                    "enabled": true,
                    "httpsOnly": true,
                    "siteConfig": {
                        "cors": {
                            "allowedOrigins": []                                                   
                        }
                    },
                    "name": "[toLower(variables('qnaMakerWebName'))]",
                    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]",
                    "hostingEnvironment": ""
                },
                "tags": {
                    "isqnamaker": "true",
                    "solution": "[parameters('resourceSolutionTag')]",
                    "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('serverFarmName')))]": "empty"
                },
                "dependsOn": [
                    "[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]",
                    "[resourceId('microsoft.insights/components', variables('appInsightsName'))]",
                    "[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]"
                ],
                "resources": [
                    {
                        "apiVersion": "2015-08-01",
                        "name": "appsettings",
                        "type": "config",
                        "dependsOn": [
                            "[resourceId('Microsoft.Web/Sites', variables('qnaMakerWebName'))]",
                            "[resourceId('Microsoft.Search/searchServices/', variables('azureSearchName'))]",
                            "[resourceId('microsoft.insights/components', variables('appInsightsName'))]"
                        ],
                        "properties": {
                            "AzureSearchName": "[variables('azureSearchName')]",
                            "AzureSearchAdminKey": "[listAdminKeys(resourceId('Microsoft.Search/searchServices/', variables('azureSearchName')), '2015-08-19').primaryKey]",
                            "UserAppInsightsKey": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').InstrumentationKey]",
                            "UserAppInsightsName": "[variables('appInsightsName')]",
                            "UserAppInsightsAppId": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').AppId]",
                            "PrimaryEndpointKey": "[concat(variables('qnaMakerWebName'), '-PrimaryEndpointKey')]",
                            "SecondaryEndpointKey": "[concat(variables('qnaMakerWebName'), '-SecondaryEndpointKey')]",
                            "DefaultAnswer": "No good match found in KB.",
                            "QNAMAKER_EXTENSION_VERSION": "latest"
                        }
                    },
                    {
                        "apiVersion": "2018-02-01",
                        "type": "config",
                        "name": "logs",
                        "dependsOn": [
                            "[resourceId('Microsoft.Web/Sites', variables('qnaMakerWebName'))]"
                        ],
                        "properties": {
                            "applicationLogs": {
                                "fileSystem": {
                                    "level": "Warning",
                                    "retentionInDays": 7
                                },
                                "azureBlobStorage": {
                                    "level": "Verbose",
                                    "sasUrl": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, parameters('storageAccountContainerQnaAppLog'), '?', listAccountSas(variables('storageAccountName'), '2018-02-01', variables('listAccountSasRequestContent')).accountSasToken)]",
                                    "retentionInDays": 7
                                }
                            },
                            "httpLogs": {
                                "fileSystem": {
                                    "retentionInMb": 35,
                                    "retentionInDays": 7,
                                    "enabled": false
                                },
                                "azureBlobStorage": {
                                    "enabled": true,
                                    "sasUrl": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, parameters('storageAccountContainerQnaWebLog'), '?', listAccountSas(variables('storageAccountName'), '2018-02-01', variables('listAccountSasRequestContent')).accountSasToken)]",
                                    "retentionInDays": 7
                                }
                            },
                            "detailedErrorMessages": {
                                "enabled": true
                            }
                        }
                    }
                ]
            }
    

    The Bot Framework Virtual Assistant is a solution accelerator that incorporates common functionality, services, and Bot Framework best practices into an easily deployable package that can then be customized to a customer’s needs. The Virtual Assistant is built on the Bot Framework SDK and is deploys within the developer’s Azure subscription on Azure Bot Service, keeping all data generated by the assistant (questions asked, user behavior, etc.) entirely in the control of the customer.

    The major components of the Virtual Assistant include:

    Visual Studio Project with code, dialog, and language generation assets

    Customizable Deployment scripts in ARM & PowerShell

    Automatic provisioning and configuration of dependent services (LUIS, QnA, Storage, Compute, etc.)

    Pluggable skills for known scenarios such as conversational use of the Microsoft Graph and Bing data assets