Host Bot in Azure for MS Teams
Overview
During previous article - Develop Bots 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 MS Azure
Follow 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.
{ "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.3/MicrosoftTeams.schema.json", "manifestVersion": "1.3", "version": "1.0.0", "id": "619674bb-c724-4fa0-b42d-22787d35f569", "packageName": "com.contoso.contentmanagement", "developer": { "name": "Office Developer", "websiteUrl": "https://www.microsoft.com", "privacyUrl": "https://www.microsoft.com/privacy", "termsOfUseUrl": "https://www.microsoft.com/termsofuse" }, "icons": { "color": "bot-icon-color-192x192.png", "outline": "bot-icon-outline-32x32.png" }, "name": { "short": "office-content-management-bot ", "full": "Office Content Management Bot" }, "description": { "short": "Office Content Management", "full": "Sample bot for the Office Content Management" }, "accentColor": "#AB00B0", "bots": [ { "botId": "619674bb-c724-4fa0-b42d-22787d35f569", "supportsFiles": true, "scopes": [ "personal", "team" ] } ], "composeExtensions": [], "permissions": [ "identity", "messageTeamMembers" ], "validDomains": [] }
-
Click Build menu, select Publish office-content-management.
- Pick a publish target as App Service.
-
Select to create new App Service.
- Click Advanced…
- Set Configuration to Release.
-
Under File Publish Options, select option Remove additional files at destination to remove outdated files during deployment.
- Click Save to close the Advanced dialog.
- Click Publish on the main screen.
-
In the Create App Service dialog, specify the needed information.
- Click Create.
-
The Bot application will be deployed to MS Azure App Service.
- Post successful deployment, the app service url will open in a browser. (e.g. https://office-content-management20190918031143.azurewebsites.net/)
Update Manifest
Follow below steps to update the manifest with App service details:
- In the visual studio, open “\office-content-management\Manifest\manifest.json”.
-
Set websiteUrl, privacyUrl, and termsOfUseUrl to the app service url.
- 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 Develop Bots For MS Teams With Bot Builder V4 SDK, 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.
Test the Bot in MS Teams
- Open MS Teams.
- From the left menu, click Chat.
- Our Bot (named OfficeContentManagement) should be listed out.
- Send the messages to Bot, it should echo back.
Summary
ngrok is used during the development phase. Once the Bot is ready it can be deployed hosted in Azure for public use. Visual Studio offers an easy option to deploy the app in Azure.
This content was originally posted here.
Leave a comment