Host Bot In Azure For MS Teams

Overview

 
In our previous article, Develop Bot For MS Teams With Bot Builder V4 SDK, we developed an Echo Bot with Bot Builder v4 utilizing ngrok to develop and test locally. ngrok is used during the development phase. It allows us to build and test the bot without publishing the app on MS Azure (or other hosting environments).
 
In this article, we will publish our app (Bot) to MS Azure and channelize to MS Teams.
 

Publish Bot to Azure

 
Follow the below steps to publish the Bot application to MS Azure App Service.
  • Open the Bot application (i.e. office-content-management) in Visual Studio.
  • Open “\office-content-management\Manifest\manifest.json”
  • Update the package name as a generic name representing Bot.
Update websiteUrl, privacyUrl, and termsOfUseUrl as an organization URL.
  1. {  
  2.   "$schema""https://developer.microsoft.com/en-us/json-schemas/teams/v1.3/MicrosoftTeams.schema.json",  
  3.   "manifestVersion""1.3",  
  4.   "version""1.0.0",  
  5.   "id""619674bb-c724-4fa0-b42d-22787d35f569",  
  6.   "packageName""com.contoso.contentmanagement",  
  7.   "developer": {  
  8.     "name""Office Developer",  
  9.     "websiteUrl""https://www.microsoft.com",  
  10.     "privacyUrl""https://www.microsoft.com/privacy",  
  11.     "termsOfUseUrl""https://www.microsoft.com/termsofuse"  
  12.   },  
  13.   "icons": {  
  14.     "color""bot-icon-color-192x192.png",  
  15.     "outline""bot-icon-outline-32x32.png"  
  16.   },  
  17.   "name": {  
  18.     "short""office-content-management-bot ",  
  19.     "full""Office Content Management Bot"  
  20.   },  
  21.   "description": {  
  22.     "short""Office Content Management",  
  23.     "full""Sample bot for the Office Content Management"  
  24.   },  
  25.   "accentColor""#AB00B0",  
  26.   "bots": [  
  27.     {  
  28.       "botId""619674bb-c724-4fa0-b42d-22787d35f569",  
  29.       "supportsFiles"true,  
  30.       "scopes": [  
  31.         "personal",  
  32.         "team"  
  33.       ]  
  34.     }  
  35.   ],  
  36.   "composeExtensions": [],  
  37.   "permissions": [  
  38.     "identity",  
  39.     "messageTeamMembers"  
  40.   ],  
  41.   "validDomains": []  
  42. }  
Click the "Build" menu, select “Publish office-content-management”.
 
Host Bot In Azure For MS Teams 
  • Pick a publish target as “App Service”.
  • Select to create a new App Service.
Host Bot In Azure For MS Teams
  • Click “Advanced…”.
  • Set Configuration to Release.
  • Under “File Publish Options”, select option “Remove additional files at destination” to remove outdated files during deployment.
Host Bot In Azure For MS Teams
  • Click "Save" to close the Advanced dialog.
  • Click "Publish" on the main screen.
  • In the “Create App Service” dialog, specify the needed information.
Host Bot In Azure For MS Teams
  • Click "Create".
  • The Bot application will be deployed to MS Azure App Service.
Host Bot In Azure For MS Teams 
  • Post successful deployment, the app service URL will open in a browser.
Host Bot In Azure For MS Teams
 

Update Manifest

 
Follow the below steps to update the manifest with App service details.
  • In Visual Studio, open “\office-content-management\Manifest\manifest.json”.
  • Set websiteUrl, privacyUrl, and termsOfUseUrl to the app service URL.
Host Bot In Azure For MS Teams
  • Build the solution. The AfterBuild target will run and compressed .zip file will be available under the bin folder.
  • Upload app into Microsoft Teams. (Follow instruction from previous article, section Upload app into Microsoft Teams).

Update Bot Channels Registration

 
From Azure portal, open the Bot Channels Registration, under settings, set the messaging endpoint as app service URL.
 
Host Bot In Azure For MS Teams
 

Test the Bot in MS Teams

  1. Open MS Teams.
  2. From the left menu, click Chat.
  3. Our Bot (named OfficeContentManagement) should be listed out.
  4. Send the messages to Bot, it should echo back.
Host Bot In Azure For MS Teams
 

Summary

 
ngrok is used during the development phase. Once the Bot is ready it can be deployed and hosted in Azure for public use. Visual Studio offers an easy option to deploy the app in Azure.