2

Summary

I am trying to deploy the latest Microsoft Virtual Assistant code. In the documentation, they describe a process to deploy and run the bot using a Visual Studio template. The whole process described in the documentation works great.

However, I don't like using a template. I don't want to loose Microsoft's Git history. Also, this deployment needs to stand the tests of time, and I want to make it as simple as possible to merge updates from Microsoft.

Inside of Microsoft's repo, there is a subdirectory containing the C# Virtual Assistant template and a sample of the code as if it were deployed by the template.

Means of preserving Git history, ability to pull new commits, etc.

I'll describe my solution, which lets me preserve Microsoft's Git history, pull their latest commits with ease and still gives me a reasonably sized project for working on my client's bot deployment (the Microsoft AI repo is huge and contains many things I don't want in my bot deployment). The resulting branch/project that I'm working on very closely resembles (vide infra, appears identical to) the solution/project that I get when I create it from the template in Visual Studio.

  1. I forked Microsoft's entire GitHub repo.
  2. I setup a local Git repository with both Microsoft's repository and my fork as remotes.
  3. I used Git subtree, as described on this Stack Overflow post to filter the repo down to just the Virtual Assistant C# sample code. I created a branch for this subtree.
  4. I copied the subtree branch into a develop branch, where I intend to do all my custom development.
  5. I can use master on Microsoft's upstream remote and the newly created subtree branch to continually pull new commits from Microsoft into my personal develop branch.

Here's some pseudo-code that roughly walks through the process.

$ git checkout upstream/master
Switched to branch upstream/master
Your branch is up to date with 'r_microsoft/master'.
$ git subtree split --prefix=templates/Virtual-Assistant-Template/csharp/sample --onto upstream/virtual-assistant-csharp -b upstream/virtual-assistant-csharp
$ git checkout upstream/virtual-assistant-csharp
$ git checkout -b eric/develop
Switched to branch 'eric/develop'
Your branch is up to date with 'r_eric/develop'.
$ git rebase upstream/virtual-assistant-csharp
Current branch eric/develop is up to date.

Deploying and running the bot

Using this subtree instead of the solution that is created from the template, I followed the directions for deployment and running the bot. Microsoft has a separate Markdown page for the deployment (linked just in case you want to check it out).

The deployment appears to run successfully. I replaced sensitive info with xxx.

PS C:\Users\eric\bot\VirtualAssistantSample> .\Deployment\Scripts\deploy.ps1 -name "personal-bot-test-using-git" -location "westus" -luisAuthoringKey "xxx" -luisAuthoringRegion "westus" -resourceGroup "personal-bot-test-using-git" -appId "xxx" -appPassword "xxx"
> Creating resource group ...
> Deploying Azure services (this could take a while)...
> Updating appsettings.json ...
> Deploying cognitive models ...
> Initializing dispatch model ...
> Parsing general LU file ...
> Deploying general LUIS app ...
> Adding general app to dispatch model ...
> Parsing chitchat LU file ...
> Deploying chitchat QnA kb ...
> Adding chitchat kb to dispatch model ...
> Parsing faq LU file ...
> Deploying faq QnA kb ...
> Adding faq kb to dispatch model ...
> Creating dispatch model...
> Done.

I did everything exactly according to their steps (besides not using the template). When I build, no errors. Running the bot shows no errors.

The web page seems to indicate that things are working.

Here's me connecting using Microsoft's Bot Emulator (replaced sensitive values).

Image of how I connected.

However, when I test the bot, no dice. It doesn't display the welcome message.

No welcome message.

And communication doesn't work.

Image showing that it's definitely not working.

Here's what the POST 400 directline.postActivity says.

{
  "error": {
    "code": "ServiceError",
    "message": "Refresh access token failed with status code: 401"
  }
}

On the other hand, if I do all the same steps, except start from the project/solution created by the template, it just works.

This magically works..

Additional Context

  • I tried the whole process using both Visual Studio 2019 and 2017 with the latest NuGet packages. There doesn't seem to be any differences.
  • With my means of getting the project started, there's no .sln file. So I open up the project using the .csproj file. Using the bot template, it creates a .sln file that I can use to open up the whole thing. Regardless of whether I open up the project that was deployed from the template using .sln or the .csproj, it works.
  • I compared the bot's directories (subtree from source code vs created by template) using WinMerge. There are no significant differences that I can see (of course I can't dig through the contents of .dll files).
  • EDIT ~ 8 hours after creating. It appears that bots created even with the template are no longer functioning?
Eric Hansen
  • 336
  • 2
  • 12

1 Answers1

1

@EricHansen and I conversed about this in his related GitHub Issue. Since the information may be valuable to others, I'll include the "answer" here:

401s are almost always caused by mismatched MicrosoftAppId/MicrosoftAppPassword. Ensure that they match in all of these locations:

  1. appsettings.json/.env/.bot, whatever is applicable
  2. The App Registration
  3. The one you use when opening Emulator

If that doesn't work, follow the Authentication Troubleshooting Guide

You should also ensure all of your packages are up to date, including:

OPs resolution was most likely related to this:

I've definitely had issues with some password strings. The README notes that it has trouble with passwords containing @. I know I've had trouble with another password, however (I don't remember what special character gave it the issue). I would guess that this was the issue.

My best guess is that it was either an issue with a special character in a password, emulator caching id/pass in some unexpected way, or IIS Express caching id/pass in some way. Usually, if I'm switching bots with the same endpoints and running into trouble, I restart those and it usually works.

mdrichardson
  • 7,141
  • 1
  • 7
  • 21