microsoft / BotBuilder-Samples

Welcome to the Bot Framework samples repository. Here you will find task-focused samples in C#, JavaScript/TypeScript, and Python to help you get started with the Bot Framework SDK!
https://github.com/Microsoft/botframework
MIT License
4.39k stars 4.88k forks source link

Echo-bot Sample code Deployment Problems on az-cli and VScode extension #3614

Closed a-MarsWang closed 2 years ago

a-MarsWang commented 3 years ago

Github issues for C# /JS / Java/ Python should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Sample information

  1. Sample type: samples
  2. Sample language: python3
  3. Sample name: echo-bot

Describe the bug

After I deploy echo-bot.zip and back to the deployment log, the error "ModuleNotFoundError: No module named 'aiohttp'" display on the log. Even if I re-zipped with aiohttp in requirements.txt, the deploymeny still went wrong.

I'd also tried to deploy on VScode via Azure Extension; however, the deployment log also had error, which is "KeyError: 'access_token'."

Command Name az webapp deployment source config-zip --resource-group {} --name {} --src echo_bot.zip

Errors:

1. Deploying by az deployment: ModuleNotFoundError: No module named 'aiohttp'
2. Deploying by vscode extension: KeyError: 'access_token'

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Expected no aiohttp module error happened when deployment.

Screenshots

Screen Shot 2021-11-29 at 9 42 03 PM

Additional context

Add any other context about the problem here.

axelsrz commented 3 years ago

Hello @a-MarsWang thanks for logging this issue, could you try deploying with the latest 3.8.X supported on azure and see if that changes the outcome?

This is probably due to an issue during the deployment process.

Thanks

dmvtech commented 3 years ago

@a-MarsWang Can you please also run the following to find the az cli version and share the output?:

az -v

a-MarsWang commented 3 years ago

@dmvtech @axelsrz Thank you for your reply.

python 3.8.x doesn't work either. Therefore, I've also tried to deploy this bot using container; however, this is the output that show on my log. Screen Shot 2021-12-01 at 12 10 34 PM Screen Shot 2021-12-01 at 12 10 00 PM

Also, this is the output using az -v The version of my az cli is 2.29.2 * Screen Shot 2021-12-01 at 12 07 14 PM

MarsWangyang commented 3 years ago

Fix the problem via VScode extension

Hi @a-MarsWang @dmvtech @axelsrz , I've found the problem that made aiohttp module not be found. I deployed this sample code via VScode extension to Web app.

Env

programming language: python 3.8 az cli version: 2.29.2.* vscode extension: Azure App Service v0.23.0

Problems I Found

There are 2 reasons that might cause the stop of the web app:

  1. In 02.echo-bot/app.py, web run(App, host="localhost", port=CONFIG.PORT) should change localhost to 0.0.0.0
  2. If you deploy via az webapp deployment source config-zip, it will show "python' is not installed" like the log I paste below.

In the second scenario(az webapp deployment), you will see that python3 and all modules in requirements.txt can't be installed. However, I follow step by step with the Microsoft doc.

Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.8 -i /tmp/8d9b4a7ff28e88b --compress-destination-dir -p virtualenv_name=antenv --log-file /tmp/build-debug.log 
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20210826.1, Commit: f8651349d0c78259bb199593b526450568c2f94a, ReleaseTagName: 20210826.1

Build Operation ID: |uno0CKmsMCk=.cf9b2109_
Repository Commit : cc91edd248eb4a62af4f5a14c8064c29

Detecting platforms...
Detected following platforms:
  python: 3.8.12
Version '3.8.12' of platform 'python' is not installed. Generating script to install it...

Using intermediate directory '/tmp/8d9b4a7ff28e88b'.

Copying files to the intermediate directory...
Done in 0 sec(s).

Source directory     : /tmp/8d9b4a7ff28e88b
Destination directory: /home/site/wwwroot

Downloading and extracting 'python' version '3.8.12' to '/tmp/oryx/platforms/python/3.8.12'...
Downloaded in 2 sec(s).
Verifying checksum...
Extracting contents...
Done in 18 sec(s).

Python Version: /tmp/oryx/platforms/python/3.8.12/bin/python3.8
Creating directory for command manifest file if it doesnot exist
Removing existing manifest file
Python Virtual Environment: antenv
Creating virtual environment...
Activating virtual environment...
Could not find setup.py or requirements.txt; Not running pip install
Not a vso image, so not writing build commands
Preparing output...

Copying files to destination directory '/tmp/_preCompressedDestinationDir'...
Done in 1 sec(s).
Compressing content of directory '/tmp/_preCompressedDestinationDir'...
Copied the compressed output to '/home/site/wwwroot'

Removing existing manifest file
Creating a manifest file...
Manifest file created.

Done in 35 sec(s).
dmvtech commented 2 years ago

Hi @a-MarsWang @MarsWangyang

I wasn't able to reproduce the issue with aiohttp when deploying using az webapp deployment. I had no problems and did not need to change localhost to 0.0.0.0.

Did you happen to do the pip install before zipping up the bot and deploying? Per documentation, this should not be done.

dmvtech commented 2 years ago

Closing due to lack of response. Please comment or reopen if you still need assistance on this issue.

boydc2014 commented 2 years ago

@dmvtech I'm able to reproduce this, can you try a linux based web app (which is now the default choice if you choose python stack), or just "az webapp up --runtime PYTHON:3.9 --sku B1 --logs" in python's echobot sample folder

breakingram commented 2 years ago

Hi @boydc2014, I'm currently investigating https://github.com/microsoft/BotBuilder-Samples/issues/3805 and I could not publish python bots.

I noticed the following pull requests for python ARM Templates and Deployment templates that was merged today.

#

Perhaps I can try to publish Python bot to see if I'm still able to repro. I will report back soon. Thanks

breakingram commented 2 years ago

Hi @boydc2014 @a-MarsWang

I was not able to reproduce this issue any more after the latest publishing docs update.

@a-MarsWang, could you please try to publish the bot from docs here: https://docs.microsoft.com/en-us/azure/bot-service/provision-and-publish-a-bot