Deploy a Basic .NET Core Bot to Azure using Visual Studio | Microsoft Bot Framework

Deploy a basic .NET C# core bot created using Bot Framework SDK to Azure. We will use Visual Studio for deploying the bot to Azure. This is one way of deployment. The other way is using the Azure CLI and ARM templates that we will be seeing later.

Prerequisites

  1. Create a Resource Group in Microsoft Azure Portal
  2. Create Azure App Service (Web App) Resource in Azure Portal
  3. Create an Azure Bot resource in Microsoft Azure Portal
  4. Get Azure Bot resource app Id
  5. Get Azure Bot Resource Password from Azure Key Vault

Deploy a Basic .NET C# Core Bot to Azure using Visual Studio

If you have received the Microsoft App ID and App Secret, mention its values in the appsettings.json file. This is optional to mention in the configuration file. You can also provide these values in the App Service (Web App) resource configuration in Azure Portal.

{
  "MicrosoftAppId": "<APP_ID>",
  "MicrosoftAppPassword": "<APP_SECRET>",
  "LuisAppId": "",
  "LuisAPIKey": "",
  "LuisAPIHostName": ""
}

Configuration is applicable for any service you use, it can be LUIS, QnA Maker, API connection strings, etc. It can be in the appsettings.json file or in the configuration settings of App Service. If you are putting in the App Service configuration, make sure the JSON property key is the same as it is present in the appsettings.json.

Right-click on the Startup project (if more than 1 project in Solution) and click on Publish.

Select Azure and click on Next to publish your bot to the Microsoft cloud.

Choose the target. If you had selected Windows during Azure App service creation, select Azure App Service (Windows) here and click on Next.

Log in to Visual Studio using your Azure account if not already done. Then, choose the Azure App Service you want the bot to be deployed on. If you have multiple subscriptions, select the subscription from the dropdown accordingly. I will deploy my bot to alexa-flight-bot. Click on Finish to create a publish profile.

Verify all the details and click on Publish to start the deployment of .NET C# Core Bot to Microsoft Azure.

This will start the build and deploy the bot to Azure. You can check the Output panel for progress. If any error occurs, the output panel will show that too.

If the web page opened shows the message that your bot is ready, then it is successfully deployed.

Now, we need to change the endpoint of the Azure Bot configuration. Go to your Azure Bot resource in Azure Portal and open the configuration settings.

The messaging endpoint will be the API. For example, my Azure App Service URL is https://alexa-flight-bot.azurewebsites.net/, then your messaging endpoint will be https://alexa-flight-bot.azurewebsites.net/api/messages. This is the same way you test the bot in the emulator. Only the hostname is changed.

Apply the changes and test the bot in Web Chat.

Thank you All!!! Hope you find this useful.


Up ↑

%d bloggers like this: