Deploy your bot

Note

This topic is for the latest release of the SDK (v4). You can find content for the older version of the SDK (v3) here.

After you have created your bot and tested it locally, you can deploy it to Azure to make it accessible from anywhere. Deploying your bot to Azure will involve paying for the services you use. The billing and cost management article helps you understand Azure billing, monitor usage and costs, and manage your account and subscriptions.

In this article, we'll show you how to deploy C# and JavaScript bots to Azure. It would be useful to read this article before following the steps, so that you fully understand what is involved in deploying a bot.

Prerequisites

  • Install latest version of the MSBot tool.
  • A CSharp or JavaScript bot that you have developed on your local machine.

Create a Web App Bot in Azure

This section is optional if you have already created a bot in Azure that you'd like to use.

  1. Log in to the Azure portal.
  2. Click Create new resource link found on the upper left-hand corner of the Azure portal, then select AI + Machine Learning > Web App bot.
  3. A new blade will open with information about the Web App Bot.
  4. In the Bot Service blade, provide the requested information about your bot.
  5. Click Create to create the service and deploy the bot to the cloud. This process may take several minutes.

Download the source code

  1. In the Bot Management section, click Build.
  2. Click on Download Bot source code link in the right-pane.
  3. Follow the prompts to download the code, and then unzip the folder.

Decrypt the .bot file

The source code you downloaded from the Azure portal includes an encrypted .bot file. You'll need to decrypt it to copy values into your local .bot file.

  1. In the Azure portal, open the Web App Bot resource for your bot.
  2. Open the bot's Application Settings.
  3. In the Application Settings window, scroll down to Application settings.
  4. Locate the botFileSecret and copy its value.

Use msbot cli to decrypt the file.

msbot secret --bot <name-of-bot-file> --secret "<bot-file-secret>" --clear

Update the .bot file

Open the .bot file you decrypted. Copy entries listed under the services section, and add them to your local .bot file. For example:

{
   "type": "endpoint",
   "name": "production",
   "endpoint": "https://<something>.azurewebsites.net/api/messages",
   "appId": "<App Id>",
   "appPassword": "<App Password>",
   "id": "2
}

Save the file.

Setup a repository

Create a git repository using your favorite git source control provider. Commit your code into the repository.

Update App Settings in Azure

  1. In the Azure portal, open the Web App Bot resource for your bot.
  2. Open the bot's Application Settings.
  3. In the Application Settings window, scroll down to Application settings.
  4. Locate the botFileSecret and delete it.
  5. Update the name of the bot file to match the file you checked into the repo.
  6. Save changes.

Deploy using Azure Deployment Center

Now, you need to connect your git repository with Azure App Services. Follow instructions in the setup continuous deployment topic. Note that it is recommended to build using App Service Kudu build server.

Test your deployment

Wait for a few seconds after a succesful deployment and optionally restart your Web App to clear any cache. Go back to your Web App Bot blade and test using the Web Chat provided in the Azure portal.

Additional resources