iT邦幫忙

2017 iT 邦幫忙鐵人賽
DAY 10
0
Cloud

認識 Microsoft Azure 三十天系列 第 10

# Azure Bot Service - Part 9 (Debugging your bot)

Azure Bot Service - Part 9 (Debugging your bot)

為了開發邏輯更為複雜的 bot,利用本機開發是必然的,只是因為 Azure Bot Services有包裝過所以開發上的設定有些小細節需要特別注意,克服這些問題就可以進入快速開發以及除錯了

必備軟體清單

C#為例,以下軟體皆會使用到,其中 Visual Studio 2017 RC 可以使用 Visual Studio 2015代替

  1. The Bot Framework Emulator
  2. The Azure Functions CLI
  3. DotNet CLI
  4. Visual Studio 2017 RC
  5. Command Task Runner

Debug 前準備

設定 Microsoft Bot Framework Emulator

  1. bot endpoint url

Azure bot service 下載回來的專案中所提供,預設為 http://localhost:3978/api/messages

  1. Microsoft App ID

bot framework 的 app id

  1. Microsoft App Password

bot framework 的 password

botemu

專案設定(擇一即可)

  1. 使用 command prompt

    • 1-1. 下載 csproj project.json 所在位置
    • 1-2. dotnet restore-->取回相依參考
    • 1-3. 取回 Azure Function 設定
      func azure functionapp fetch-app-settings {YOUR_BOT_SERVICE_NAME}
      • 執行debughost.cmd時,無相關設定的提示訊息
      ----------------------------------------------------------------------
      To fetch your bot service settings run the following command:
       func azure functionapp fetch-app-settings [YOUR_BOT_SERVICE_NAME]
      ----------------------------------------------------------------------
      
      Function completed (Failure, Id=7*******************************6d)
       ScriptHost error has occurred
      xception while executing function: Functions.messages. 			 			Microsoft.Bot.Connector: Authorization for Microsoft App ID  failed with status code Unauthorized.
      

      fetchsetting
      fetchsettingERROR

  2. 使用 Visual Studio 2017 RC

    • 2-1. 下載csproj project.json 所在位置

    • 2-2. Restore Nuget Packages

      vsrestore

    • 2-3. 取回 Azure Function 設定
      func azure functionapp fetch-app-settings {YOUR_BOT_SERVICE_NAME}

      執行debughost.cmd時,無相關設定的提示訊息

      ---------------------------------------------------------------------
      o fetch your bot service settings run the following command:
      func azure functionapp fetch-app-settings [YOUR_BOT_SERVICE_NAME]
      ---------------------------------------------------------------------
      ``
      

      Function completed (Failure, Id=7*******************************6d)
      A ScriptHost error has occurred
      Exception while executing function: Functions.messages. Microsoft.Bot.Connector: Authorization for Microsoft App ID failed with status code Unauthorized.

       ![VSfetchsetting](https://trello-attachments.s3.amazonaws.com/5839ddfe731a78bc5eac486b/1200x358/b1b354852fcac90b0cc8e4c139b8de7f/_output_VSfetchsetting.png)
       ![VSfetchsettingERROR](https://trello-attachments.s3.amazonaws.com/5839ddfe731a78bc5eac486b/1033x351/7f9e9eacf6ccbdce3668174be9fefaa1/_output_VSfetchsettingERROR.png)
      
      

開始 debug

  • Microsoft Bot Framework Emulator
    送出訊息,右下Log區可以檢視回應,點選 log 可以在上方的 Details 區看到詳細內容

cmdemuok

  1. 使用 command prompt
    debughost.cmd

確認有收到以及正常執行
cmdreceive

  1. 使用 Visual Studio 2017 RC
    2-1.Task Runner Explorer

執行服務
RUN
確認有收到以及正常執行
vstaskreceive

2-2. F5 直接逐步偵錯

sending
f5debug

參考資料

  1. Debugging your bot
  2. The Bot Framework Emulator
  3. The Azure Functions CLI
  4. DotNet CLI
  5. Visual Studio 2017 RC
  6. Command Task Runner

上一篇
Azure Bot Service - Part 8 (設定 持續性整合)
下一篇
Azure Bot Service - Part 10 (如何新增 Channel)
系列文
認識 Microsoft Azure 三十天31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言