Deploying A Bot To Azure Using Visual Studio 2017

Introduction

The Bot Framework enables you to build bots that support different types of interactions with users. You can design conversations in your bot to be freeform. Your bot can also have more guided interactions where it provides the user choices or actions. The conversation can use simple text strings or more complex rich cards that contain text, images, and action buttons. And you can add natural language interactions, which let your users interact with your bots in a natural and expressive way.

In this article, we can deploy a bot to Azure using visual studio 2017, register app with bot portal and test it with the Bot Framework Emulator.

Setup and Create New Bot Application.

You can read my previous article for Getting Started with Bots Using Visual Studio 2017 from following URL http://www.c-sharpcorner.com/article/getting-started-with-bots-using-visual-studio-2017/
Bot Application
You need an Azure account for deploying bot applications to Azure so if you do not have an Azure account, you can click the following url for a free trial Azure subscription. https://azure.microsoft.com/en-us/free/

Register Bot Application

Step 1

Navigate to Bot Framework Portal from https://dev.botframework.com/

Step 2

Click on Sign in button and login with credential

Step 3

Click on Create a Bot or Skill

Step 4

Click on Create a Bot and click on Register

Step 5

Upload relevant app png icon and max size should be 30k

Step 6

Provide your bot's Display Name.

Step 6

Provide a Description of your bot.
Bot Application
Step 7

Provide your bot's Https endpoint in configuration section.

  • We have not yet deployed our bot to the cloud so leave the endpoint blank for now. We will return to the Bot Framework Portal later and specify the endpoint after we have deployed our bot.

Step 8

On the next page, click Generate an app password to continue.

Step 9

Copy and securely store the password that is shown, and then click Ok.

Step 10

Click Finish and go back to Bot Framework.

Step 11

Back in the Bot Framework Portal, the App ID field is now populated.

Click 12

Click on Register to complete the registration process.

Update Web Configuration file

Open your project in Visual Studio and update the Microsoft App Id and Microsoft App Password values in your web configuration settings to specify the app ID and password values that were generated for your bot during the above registration process.

Bot Application 

  1. <appSettings>  
  2.     <!-- update these with your BotId, Microsoft App Id and your Microsoft App Password-->  
  3.     <add key="BotId" value="DevEnvExeBot" />  
  4.     <add key="MicrosoftAppId" value="2f3edda3-d36d-4d88-8acf-e448d870348e" />  
  5.     <add key="MicrosoftAppPassword" value="L6KOPcc3jqZB6hKPe06yxsH" />  
  6.   </appSettings>  

Azure publishing wizard

Step 1

Right click on Project > Select on Publish and start publish bot application into azure

Bot Application

Step 2

Select on Microsoft Azure App Service > select on Create New and click on Publish button
Bot Application
Step 3

Login with Microsoft Azure account and click on create app service

Bot Application

Step 4

Copy the Destination URL value to the clipboard (you'll need this value later to test the connection to the bot)

Bot Application

Update Site Url from Bot Portal

Step 1

Sign in to the Bot framework Portal - https://dev.botframework.com/

Step 2

Click My Bots.

Step 3

Select the bot that you want to configure and click Settings.

Step 4

Provide your bot's HTTPS endpoint. This is the endpoint where your bot will receive HTTP POST messages from Bot Connector. If you built your bot by using the Bot Builder SDK, the endpoint should end with /api/messages.
Bot Application

Step 5

Click on Save Changes.

Test Bot Application on Portal

After publish Bot application into azure, you can test bot application from portal and emulator .

Step 1

Sign in to the Bot framework Portal - https://dev.botframework.com/

Step 2

Click on Test and provide input text

Bot Application

Test Bot Application on Emulator

  1. Open Bot Emulator and Provide your bot's HTTPSendpoint with api/messages .
  2. Provide Microsoft App ID and Password and click on Connect

    Bot Application

If you are getting the following error, Click on Edit Tunneling (ngrok) setting.

Bot Application

Download Tunneling (ngrok.exe) from https://ngrok.com/download and click on browse and associate ngrok.exe path

Bot Application

Click on refresh from Bot emulator and provide your input for test application

Bot Application

Summary

In this article, your learned how to Deploy a bot to Azure using Visual Studio 2017. If you have any questions/ feedback/ issues, please write in the comment box.

Up Next
    Ebook Download
    View all
    Learn
    View all