Deploy a bot to Azure from Visual Studio

When you build a bot with Visual Studio, you can take advantage of its built-in publish capability. This tutorial shows you to how deploy a bot to Azure directly from Visual Studio.

Note

If you created a bot with the Azure Bot Service, your bot deployment was part of the Azure Bot Service bot creation process.

Prerequisites

You must have a Microsoft Azure subscription before you can deploy a bot to Azure. If you do not already have a subscription, you can register for a free trial. Additionally, the process described by this article requires Visual Studio. If you do not already have Visual Studio, you can download Visual Studio 2017 Community for free.

Application settings and HTTPS

Verify application settings

For your bot to function properly in the cloud, you must ensure that its application settings are correct. If you've already registered your bot with the Bot Framework, update the Microsoft App Id and Microsoft App Password values in your application's configuration settings as part of the deployment process. Specify the app ID and password values that were generated for your bot during registration.

Tip

If you're using the Bot Builder SDK for Node.js, set the following environment variables:

  • MICROSOFT_APP_ID
  • MICROSOFT_APP_PASSWORD
If you're using the Bot Builder SDK for .NET, set the following key values in the web.config file:
  • MicrosoftAppId
  • MicrosoftAppPassword

If you have not yet registered your bot with the Bot Framework (and therefore do not yet have an app ID and password), you can deploy your bot with temporary placeholder values for these settings. Then later, after you register your bot, update your deployed application's settings with the app ID and password values that were generated for your bot during registration.

Verify HTTPS endpoint

Your deployed bot must have an HTTPS endpoint that can receive messages from the Bot Framework Connector Service.

Note

When you deploy your bot to Azure, SSL will automatically be configured for your application, thereby enabling the HTTPS endpoint that the Bot Framework requires. If you deploy to another cloud service, be sure to verify that your application is configured for SSL so that the bot will have an HTTPS endpoint.

Step 1: Launch the Microsoft Azure Publishing Wizard in Visual Studio

Open your project in Visual Studio. In Solution Explorer, right-click on the project and select Publish. This starts the Microsoft Azure publishing wizard.

Right-click on the project and choose Publish to start the Microsoft Azure publishing wizard

Step 2: Use the Azure Publishing Wizard to publish your bot to the cloud

Select Microsoft Azure App Service as the project type and click Next.

Select Microsoft Azure App Service and click Next

Create your App Service by clicking New… on the right side of the dialog.

Click New to create a new Azure App Service

Click Change Type and change the service's type to Web App. Then, name your web app and fill out the rest of the information as appropriate for your implementation.

Name your App Service, then click New App Service Plan to define one

Click Create to create your app service.

Create the App Service Plan by clicking Create

Copy the Destination URL value to the clipboard (you'll need this value later to test the connection to the bot), and then click Validate Connection to verify that the settings have been configured correctly. If validation is successful, click Next.

Validate Connection and click Next to proceed to the final step.

By default, your bot will be published in a Release configuration. (If you want to debug your bot, change Configuration to Debug.) Click Publish to publish your bot to Microsoft Azure.

Select Release Configuration and click Publish

Note

During the publishing process, you will see a number of messages displayed in the Visual Studio 2017 Output window. When publishing completes, your bot's HTML page will be displayed in your default browser.

Step 3: Test the connection to your bot

Verify the deployment of your bot by using the Bot Framework Emulator.

Enter the bot's HTTPS endpoint into the address bar of the Emulator. If you built your bot with the Bot Builder SDK, the endpoint should end with /api/messages Example: https://<appname>.azurewebsites.net/api/messages

Next steps

After you have deployed your bot to the cloud and verified that the deployment was successful by testing the bot using the Bot Framework Emulator, the next step in the bot publication process will depend upon whether or not you've already registered your bot with the Bot Framework.

If you have already registered your bot with the Bot Framework:

  1. Return to the Bot Framework Portal and update your bot's registration data to specify the HTTPS endpoint for the bot.

  2. Configure the bot to run on one or more channels.

If you have not yet registered your bot with the Bot Framework:

  1. Register your bot with the Bot Framework.

  2. Update the Microsoft App Id and Microsoft App Password values in your deployed application's configuration settings to specify the app ID and password values that were generated for your bot during the registration process.

  3. Configure the bot to run on one or more channels.