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.
In the Pick a publish target dialog, ensure App Service is selected on the left and Create New is selected on the right.
Click the Publish button.
In upper right of the dialog, ensure the dialog is showing the correct user ID for your Azure subscription.
Enter App Name, Subscription, Resource Group, and Hosting Plan information.
When ready, click Create. It can take a few minutes to complete the process.
Once complete, a web browser will open showing your bot’s public URL.
Make a copy of this URL (it will be something like https://
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.
Access the Azure Portal at https://portal.azure.com.
Log in using the same identity you used earlier from Visual Studio to publish your bot.
Click Create a resource.
In the Search the Marketplace field type Bot Channels Registration and press Enter.
In the returned list, choose Bot Channels Registration:
Click create in the blade that opens.
Provide a Name for your bot.
Choose the same Subscription where you deployed your bot’s code.
Pick your existing Resource group which will set the location.
You can choose the F0 Pricing tier for development and testing.
Enter your bot’s URL. Make sure you start with HTTPS and that you add the /api/messages For example https://yourbotname.azurewebsites.net/api/messages
Turn off Application Insights for now.
Click the Microsoft App ID and password
In the new blade click Create New.
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.
In the new tab, make a copy of the App ID and save it somewhere.
Click the Generate an app password to continue button.
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.
Click OK once you’ve got the password saved.
Just close the browser tab and return to the Azure Portal tab.
Paste in your App ID and Password in the correct fields and click OK.
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.
- Click App Services. Type your bot’s name in the Subscriptions text box. Then click on your bot's name in the list.
- In the list of options on the left within your bot's options, locate Application Settings in the Settings section and click it.
- Scroll until you find the Application settings section.
Click Add new setting.
Type MicrosoftAppId for the name and your App ID for the value.
Click Add new setting
Type MicrosoftAppPassword for the name and your password for the value.
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.
Go back to your Resource group in the Azure portal
Open your bot.
Under Bot management, select Test in Web Chat.
- Type a message like
Hiand press Enter. The bot will echo back
Turn 1: You sent Hi.
When you deploy a bot, typically these reources are created in the Azure portal:
|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.