Automating Deployment in Bot Framework (Bot + LUIS+ QnA + Table Storage)
P

2

6

We have a bot deployed on Azure but we want to give it to a client so he can deploy it run it using his own resources. We need to give them a Powershell script that magically create and deploy all the resources needed for the bot to work. My bot architecture consists on the following parts:

  • Bot's Logic (ASP.NET Web API Project deployed over an Azure App Service)
  • LUIS Model (published over a Cognitive Services Account)
  • QnA Service Knowledge Base done with QnA Maker (published directly from the QnaMaker Portal (have no idea where it's deployed)
  • Azure Table Storage

My Questions are:

1) How to configure bots web api to connection strings parameters? (table storage, luis and qna service will be different when they re redeployed) Currently I am defining the conn. strings and api keys on the web.config, but as I said, this needs to be dynamic.

2) How to automate deployment for LUIS? Luis needs to have the Key of the Cognitive Services Account that should be created first. And I assume I have the exported model json file. I was thinking of using the LUIS API to do the app export and the publishing part. Would that be enough?

3) How to deploy qna services? I think currently is deployed somewhere magically so maybe I won't need to do anything with it.

Thanks!

Pensive answered 3/4, 2017 at 18:36 Comment(5)
Have you looked at your Resource Group's Automation script in the Azure portal? ARM reference: learn.microsoft.com/en-us/azure/azure-resource-manager/…Distillery
Yes, I know it, but that doesn't solve the parameters being dynamic on the web api web.config.Pensive
I just came across this info: "Right now we do not have a paid subscription model, however we have introduced a premium subscription tier with increased quotas, to encourage production deployments of the service. The premium tier is invite only, if you are interested please fill this request:" forms.office.com/Pages/…Distillery
Yep. It was me the one who asked the question on GithubPensive
I've been asking around. What I've gathered so far: automating the deployment of connection strings for table storage is the same for a Bot as it is for any other Web App deployed to Azure. However, there is currently no way to easily automate or script such things as Bot Registration and QNA services setup. Apparently, you will need to manually create these things using a client transferable account. Also, please note that the Bot Framework, LUIS, and QNA Services are all currently in preview and actively being improved upon daily.Distillery
C
2

Maybe a little bit late, but I just had to implement the very same thing, so here are the answers to your questions in hope they could be useful to others:

1) As JoyrexJ9 mentioned above, you can do this via an ARM template by setting the Application Settings of your App Service which will override the values in your Web.config. More about this here.

  • You can put together and set the connection string of a storage account in the ARM template like this:

{
  "type": "Microsoft.Web/sites",
  "kind": "app",
  "name": "MyWebApp",
  "apiVersion": "2015-08-01",
  "location": "westeurope",
  "properties": {
    "name": "MyWebApp",
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', 'MyAppServicePlanName')]",
    "siteConfig": {
      "appSettings": [{
        "name": "StorageConnectionString",
        "value": "[concat('DefaultEndpointsProtocol=https;AccountName=','MyStorageAccountName',';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', 'MyStorageAccountName'), '2017-10-01').keys[0].value,';EndpointSuffix=core.windows.net')]"
      }],
      "cors": {
        "allowedOrigins": [
          "*"
        ]
      }
    }
  },
  "dependsOn": [
    "[resourceId('Microsoft.Storage/storageAccounts/', 'MyStorageAccountName')]",
    "[resourceId('Microsoft.Web/serverfarms', 'MyAppServicePlanName')]"
  ]
}
  • For LUIS and QnA maker you will need to get the values from the respective portals manually and either update the App Settings after the ARM deployment manually, or re-run the ARM deployment with the manually acquired values passed to it as parameters. The latter works because for the first time you can leave those values empty in your ARM template, and when you deploy it the second time with the parameter values in place, ARM will simply update those App Settings values. More on this topic here. (Hint: if you provision the QnA Maker and LUIS apps programmatically through their API-s, then you'll only need to get the subscription key for LUIS manually, because you'll get the knowledge base's credentials from QnA Maker's API.)

2) Unfortunately you cannot automate the provisioning of a LUIS app completely at the moment. You can create the resource in Azure via an ARM template and you can do the bulk of the rest of the work through the LUIS API, but for example you cannot assign the subscription key created by the ARM template to a LUIS app programmatically, because that API method is deprecated.

3) The QnA Maker service and it's hosting model changed significantly since you've submitted your questions. I wrote a full blog post about how to do the provisioning of it in the new system.

As JoyrexJ9 mentioned above, it's very important to point out that you won't be able to automate the bot registration fully even with a script, because there's no API for registering an application at https://apps.dev.microsoft.com/. You'll have to do that manually as well. Everything else (besides the things I mentioned above) can be fully automated either via ARM templates or scripts.

Catalogue answered 20/9, 2018 at 12:19 Comment(0)
V
0

Some of this you can automate with ARM templates, you can use functions like listKeys() to query the connection keys of one resource and use it as parameters for another resource. If you use Azure App Services you can override settings in web.config with what are called App Settings, and these can be set inside an ARM template

Check out this ARM template which deploys a bot and dynamically links it to a newly deployed cognitive service

The bot and app-id registration I don't think you can currently automate, there's no API or CLI

Villasenor answered 13/5, 2017 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.