Deploy your C# bot using Visual Studio


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 a C# bot using Visual Studio and the Azure portal. It would be useful to read this article before following the steps, so that you fully understand what is involved in deploying a bot.


Deploy your bot in App Service

You will first deploy the bot to Azure from Visual Studio in an App Service. Then you’ll configure your bot with the Azure Bot Service using Bot Channels Registration.

Note: If your Visual Studio project name has spaces, the deployment steps outlined below will not work.

In the Solution Explorer window, right click on your project’s node and select Publish.

publish setting

  1. In the Pick a publish target dialog, ensure App Service is selected on the left and Create New is selected on the right.

  2. Click the Publish button.

  3. In upper right of the dialog, ensure the dialog is showing the correct user ID for your Azure subscription.

publish main

  1. Enter App Name, Subscription, Resource Group, and Hosting Plan information.

  2. When ready, click Create. It can take a few minutes to complete the process.

  3. Once complete, a web browser will open showing your bot’s public URL.

  4. Make a copy of this URL (it will be something like


You’ll need to use the HTTPS version of the URL when registering your bot. Azure provides SSL support with Azure App Service.

Create your bot channels registration

With your bot deployed in Azure you need to register it with the Azure Bot Service.

  1. Access the Azure Portal at

  2. Log in using the same identity you used earlier from Visual Studio to publish your bot.

  3. Click Create a resource.

  4. In the Search the Marketplace field type Bot Channels Registration and press Enter.

  5. In the returned list, choose Bot Channels Registration:


  1. Click create in the blade that opens.

  2. Provide a Name for your bot.

  3. Choose the same Subscription where you deployed your bot’s code.

  4. Pick your existing Resource group which will set the location.

  5. You can choose the F0 Pricing tier for development and testing.

  6. Enter your bot’s URL. Make sure you start with HTTPS and that you add the /api/messages For example

  7. Turn off Application Insights for now.

  8. Click the Microsoft App ID and password

  9. In the new blade click Create New.

  10. In the new blade that opens to the right, click the "Create App ID in the App Registration Portal" which will open in a new browser tab.

bot msa

  1. In the new tab, make a copy of the App ID and save it somewhere.

  2. Click the Generate an app password to continue button.

  3. A browser dialog opens and provides you with your app’s password, which will be the only time you get it. Copy and save this password somewhere you can get to later.

  4. Click OK once you’ve got the password saved.

  5. Just close the browser tab and return to the Azure Portal tab.

  6. Paste in your App ID and Password in the correct fields and click OK.

  7. Now click Create to set up your channel registration. This can take a few seconds to a few minutes.

Update your bot’s Application Settings

In order for your bot to authenticate with the Azure Bot Service, you need to add two settings to your Bot’s Application Settings in Azure App Service.

  1. Click App Services. Type your bot’s name in the Subscriptions text box. Then click on your bot's name in the list.

app service

  1. In the list of options on the left within your bot's options, locate Application Settings in the Settings section and click it.

bot id

  1. Scroll until you find the Application settings section.

bot msa

  1. Click Add new setting.

  2. Type MicrosoftAppId for the name and your App ID for the value.

  3. Click Add new setting

  4. Type MicrosoftAppPassword for the name and your password for the value.

  5. Click the Save button up top.

Test Your Bot in Production

At this point, you can test your bot from Azure using the built-in Web Chat client.

  1. Go back to your Resource group in the Azure portal

  2. Open your bot.

  3. Under Bot management, select Test in Web Chat.

test in webchat

  1. Type a message like Hi and press Enter. The bot will echo back Turn 1: You sent Hi.

Additional resources

When you deploy a bot, typically these reources are created in the Azure portal:

Resources Description
Web App Bot An Azure Bot Service bot that is deployed to an Azure App Service.
App Service Enables you to build and host web applications.
App Service plan Defines a set of compute resources for a web app to run.
Application Insights Provides tools for collecting and analyzing telemetry.
Storage account Provides cloud storage that is highly available, secure, durable, scalable, and redundant.

If you are unfamiliar with Azure resource group, see this terminology topic.

Next steps