Botframework-sdk: Hosting Bot Framework .NET in linux

Created on 2 Jun 2020  Â·  3Comments  Â·  Source: microsoft/botframework-sdk

Bot Services customer-replied-to customer-reported

Most helpful comment

@Vigneshramkumar

It can indeed be done. At one point, we were going to write a blog post about it, but it got nixed. It's slightly dated, but should get you going just fine. Here it is:

Hosting a NetCore Bot on Azure Linux App Service

Microsoft Bot Builder dotnet SDK V4 targets netstandard2.0, which is cross platform. This enables bots to be hosted on an Azure Linux App Service. This blog post will demonstrate creating an Azure Linux App Service and deploying a locally created dotnet bot to that App Service.

You can follow the steps in this article using a Mac, Windows, or Linux machine.

Prerequisites

Azure Cloud Shell

First, we need to create the appropriate resources in Azure so that we have somewhere to push our locally developed bot.

  1. Open Azure Cloud Shell in your browser and login to your Azure account.
  2. Create a deployment user, if you do not have one already.

    • az webapp deployment user set --user-name <username> --password <password>

  3. Create a Resource Group

    • az group create --name <resource-group> --location <location>

  4. Create a Linux App Service Plan

    • az appservice plan create --name <service-plan-name> --resource-group <resource-group> --sku B1 --is-linux

  5. Create the dotnetcore2.1 web app

    • az --% webapp create --resource-group <resource-group> --plan <service-plan-name> --name <app-name> --runtime "DOTNETCORE|2.1" --deployment-local-git

Note: --% prevents Azure Shell/Powershell from parsing anything after it.

Save the deploymentLocalGitUrl, it will be needed in step 4 below. The format of this url is:

https://[email protected]/WebAppName.git

Create an EchoBot on Your Local Machine and push to Azure

Note: You can use any C# bot, but steps 1-3 will help you create one if you don't already have one.

Execute These Commands on your Local Machine

  1. Install the EchoBot template

    • dotnet new -i Microsoft.Bot.Framework.CSharp.EchoBot

  2. Generate an Echo Bot (netcoreapp2.1)

    • dotnet new echobot --framework netcoreapp2.1 -n <app-name>

  3. Enter the directory you just created

    • cd <app-name>

  4. Initialize Git and add first commit

    • git init

    • git add .

    • git commit -m "first commit"

  5. Add Azure remote repository

    • git remote add azure <deploymentLocalGitUrl-from-create-step>

  6. Push local bot to Azure

    • git push azure master

    • Use the username and password you set in the "Create a deployment user" step.

You should now see your bot hosted in the Azure Portal under Azure Portal -> Resource Groups -> <resource-group>:

Create an App Registration and Web App Bot so You Can Talk to Your Bot

  1. Create the App Registration

    • az ad app create --display-name <app-name> --password <password->-16-characters> --available-to-other-tenants

  2. Copy the appId given near the top of the output.
  3. Create the Web App Bot

    • az bot create --kind webapp --resource-group <resource-group> --name <app-name> --appid <appId-from-previous-step> --password <password->-16-characters> --lang "Csharp" --location <location>

  4. Test your bot by going to the Azure Portal under Azure Portal -> Resource Groups -> <resource-group> -> Web App Bot -> Test in Web Chat:

image

References

All 3 comments

Hello All,
Is it possible to deploy the Bot framework V4 of .NET in the Linux server and provide that as a messaging endpoint by registering Not channels registration in Azure?

@Vigneshramkumar

It can indeed be done. At one point, we were going to write a blog post about it, but it got nixed. It's slightly dated, but should get you going just fine. Here it is:

Hosting a NetCore Bot on Azure Linux App Service

Microsoft Bot Builder dotnet SDK V4 targets netstandard2.0, which is cross platform. This enables bots to be hosted on an Azure Linux App Service. This blog post will demonstrate creating an Azure Linux App Service and deploying a locally created dotnet bot to that App Service.

You can follow the steps in this article using a Mac, Windows, or Linux machine.

Prerequisites

Azure Cloud Shell

First, we need to create the appropriate resources in Azure so that we have somewhere to push our locally developed bot.

  1. Open Azure Cloud Shell in your browser and login to your Azure account.
  2. Create a deployment user, if you do not have one already.

    • az webapp deployment user set --user-name <username> --password <password>

  3. Create a Resource Group

    • az group create --name <resource-group> --location <location>

  4. Create a Linux App Service Plan

    • az appservice plan create --name <service-plan-name> --resource-group <resource-group> --sku B1 --is-linux

  5. Create the dotnetcore2.1 web app

    • az --% webapp create --resource-group <resource-group> --plan <service-plan-name> --name <app-name> --runtime "DOTNETCORE|2.1" --deployment-local-git

Note: --% prevents Azure Shell/Powershell from parsing anything after it.

Save the deploymentLocalGitUrl, it will be needed in step 4 below. The format of this url is:

https://[email protected]/WebAppName.git

Create an EchoBot on Your Local Machine and push to Azure

Note: You can use any C# bot, but steps 1-3 will help you create one if you don't already have one.

Execute These Commands on your Local Machine

  1. Install the EchoBot template

    • dotnet new -i Microsoft.Bot.Framework.CSharp.EchoBot

  2. Generate an Echo Bot (netcoreapp2.1)

    • dotnet new echobot --framework netcoreapp2.1 -n <app-name>

  3. Enter the directory you just created

    • cd <app-name>

  4. Initialize Git and add first commit

    • git init

    • git add .

    • git commit -m "first commit"

  5. Add Azure remote repository

    • git remote add azure <deploymentLocalGitUrl-from-create-step>

  6. Push local bot to Azure

    • git push azure master

    • Use the username and password you set in the "Create a deployment user" step.

You should now see your bot hosted in the Azure Portal under Azure Portal -> Resource Groups -> <resource-group>:

Create an App Registration and Web App Bot so You Can Talk to Your Bot

  1. Create the App Registration

    • az ad app create --display-name <app-name> --password <password->-16-characters> --available-to-other-tenants

  2. Copy the appId given near the top of the output.
  3. Create the Web App Bot

    • az bot create --kind webapp --resource-group <resource-group> --name <app-name> --appid <appId-from-previous-step> --password <password->-16-characters> --lang "Csharp" --location <location>

  4. Test your bot by going to the Azure Portal under Azure Portal -> Resource Groups -> <resource-group> -> Web App Bot -> Test in Web Chat:

image

References

@mdrichardson - Thanks for your response. We are planning to deploy the bot builder in our environment (not in Azure) and register the same in Azure using Bot Channels Registration. Kindly close the issue if my assumption is right. Again thanks for your quick response.

Was this page helpful?
0 / 5 - 0 ratings