通过模板部署和运行bot框架v4.4 +可以运行,但是使用fork和源代码控制的部署和运行不起作用

时间:2019-05-08 18:59:46

标签: c# templates version-control botframework

摘要

我正在尝试部署最新的Microsoft Virtual Assistant code。在文档中,他们describe a process使用Visual Studio template部署和运行机器人。文档中描述的整个过程效果很好。

但是,我不喜欢使用模板。我不想失去微软的Git历史。此外,此部署还需要经受时间的考验,我想使其尽可能简单,以合并来自Microsoft的更新。

Microsoft's repo内,有一个subdirectory,其中包含C#虚拟助手template和一个sample of the code as if it were deployed by the template

保存Git历史记录的能力,拉出新提交的能力等。

我将描述我的解决方案,该解决方案使我可以保留Microsoft的Git历史记录,轻松进行其最新提交,并且仍为我提供了一个合理大小的项目来进行客户端的bot部署(Microsoft AI回购是巨大的,包含很多东西我不想在我的机器人程序中部署)。我正在处理的分支/项目与从Visual Studio模板中创建的解决方案/项目非常相似(见下文,看上去完全相同)。

  1. forked Microsoft's entire GitHub repo
  2. 我使用Microsoft的存储库和我的fork作为远程服务器,设置了一个本地Git存储库。
  3. 我使用了Stack Overflow post所述的Git子树,将存储库过滤为Virtual Assistant C# sample code。我创建了branch for this subtree
  4. 我将子树分支复制到了开发分支,在那里我打算进行所有自定义开发。
  5. 我可以在Microsoft的上游远程服务器和新创建的子树分支上使用master,以不断将来自Microsoft的新提交拖到我的个人开发分支中。

下面是一些伪代码,大致介绍了整个过程。

$ 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.

部署和运行机器人

使用这个子树而不是从模板创建的解决方案,我遵循directions进行部署和运行机器人。微软有一个separate Markdown page for the deployment(如果您想签出该链接,则为链接)。

部署似乎已成功运行。我用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.

我完全按照他们的步骤进行了所有操作(除了不使用模板外)。当我建立时,没有错误。运行该机器人不会显示任何错误。

The web page seems to indicate that things are working.

这是我使用Microsoft's Bot Emulator(替换为敏感值)进行的连接。

Image of how I connected.

但是,当我测试机器人时,没有骰子。它不会显示欢迎消息。

No welcome message.

通信无法正常工作。

Image showing that it's definitely not working

这就是POST 400 Directline.postActivity所说的。

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

另一方面,如果我执行所有相同的步骤,除了从模板创建的项目/解决方案开始,它就可以正常工作。

This magically works.

其他上下文

  • 我使用Visual Studio 2019和2017和最新的NuGet软件包尝试了整个过程。似乎没有任何区别。
  • 使用我的项目启动方法,没有.sln文件。因此,我使用.csproj文件打开了项目。使用bot模板,它将创建一个.sln文件,我可以用它来打开整个内容。不管我打开使用.sln还是.csproj从模板部署的项目,它都可以工作。
  • 我使用WinMerge比较了漫游器的目录(源代码的子树与模板创建的子树)。我看不到任何明显的差异(当然,我无法浏览.dll文件的内容)。
  • 在创建后约8小时进行编辑。看来使用模板创建的漫游器不再起作用?

1 个答案:

答案 0 :(得分:1)

@EricHansen和我在his related GitHub Issue中进行了交谈。由于这些信息可能对其他人有价值,因此我将在此处添加“答案”:

401几乎总是由不匹配的MicrosoftAppId / MicrosoftAppPassword引起的。确保它们在所有这些位置都匹配:

  1. appsettings.json / .env / .bot,只要适用
  2. The App Registration
  3. 打开模拟器时使用的那个

如果这不起作用,请遵循Authentication Troubleshooting Guide

您还应该确保所有软件包都是最新的,包括:

OP分辨率最可能与此有关:

  

我肯定遇到了一些密码字符串的问题。 The README指出使用包含@的密码有麻烦。我知道我已经   遇到其他密码的问题,但是(我不记得了   特殊字符给了这个问题)。我想这就是   问题。

     

我最好的猜测是这是一个有特殊字符的问题   使用密码,模拟器以某种意外的方式缓存ID /或IIS   以某种方式表示缓存ID /传递。通常,如果我要切换机器人   具有相同的端点并遇到麻烦,我重新启动它们,然后   通常可以正常工作。