简体   繁体   中英

How to deploy Microsoft botbuilder nodejs app to azure using CLI?

I am trying to deploy the basic-bot Microsoft Botbuilder sample application to azure.

I started by creating a new botbuilder node.js sample application through the Azure dashboard, and I was able to successfully follow the instructions here to download and redeploy the application.

I then attempted to copy over the deploy scripts and .env file from the downloaded sample application into the basic-bot application, and attempted to publish using the az bot publish command from the link above. This successfully deployed the basic-bot application, but the deployed application now returns 500 errors. Initially, the 500 errors were caused by the "botbuilder-ai" nodejs package not being installed. I installed this package manually through the Azure console, and this error went away. But the application continues throw 500 errors, without producing a stack trace, and I have not been able to determine why.

The only official documentation I have found that explains how to deploy the bot is specifically for C# and Visual Studio. Is there a way to deploy a bot to azure for a Node.js app using the azure CLI?

Thank you.

Is there a way to deploy a bot to azure for a Node.js app using the azure CLI?

Yes there is. You can type az bot publish -h for all the options available to you when publishing a bot. Here are some tips about getting it to work:

  • You will need to log in to Azure with az login
  • Make sure you've set an active subscription. Type az account set -h for help. Use az account list to see your choices of subscriptions and az account show to see the current active subscription
  • Publishing can be easier if you set the resource group you're publishing to as your default. Unlike your active subscription, configured defaults don't reset when you log out. Use az configure to see your current defaults and az configure -h to see how to set a default resource group
  • If you publish and it says Not a valid azure publish directory. missing post deploy scripts Not a valid azure publish directory. missing post deploy scripts then you'll need a PostDeployScripts folder in your bot folder

There are some instructions in the deploymentScripts folder that you might find helpful. Note that as an alternative to the Azure CLI, you can also publish from Visual Studio Code using the Azure App Service extension.

If you publish successfully and you're getting errors when you try to test in Web Chat, sometimes Azure needs a little nudging. When I checked my Channels blade it said Web Chat was encountering errors regarding missing files. I tried some troubleshooting steps and eventually got it to work without any real changes.

  • Try logging out of your Azure account in the online portal and then logging back in
  • Try running your code in the online code editor in the Build blade
  • Try publishing again

Regarding your specific situation of trying to repurpose the downloaded source code to deploy the basic-bot sample, there are a few things you need to know. The .bot file is very important as it contains information about all the services the bot uses, but basic-bot.bot contains none of the needed information. In addition to the deployment scripts and the .env file you will also need to copy over your .bot file. However, basic-bot's bot.js expects the .bot file to contain a LUIS service named "basic-bot-LUIS" so you need to go into the bot.js code and change the value of LUIS_CONFIGURATION to the name of the LUIS service in your .bot file ("BasicBotLuisApplication" if you downloaded the V4 Basic Bot NodeJS code and kept it the same). Make sure you can get the basic-bot sample to run locally before you try to publish it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM