0

I am trying to deploy a bot to Azure built on Microsoft Bot Framework in Python. The Bot is working locally on Bot Emulator. Using Visual Studio Code for the bot development.

Deployed the Bot to Azure on a WebApp successfully using the startup command as :

python3.7 -m aiohttp.web -H 0.0.0.0 -P 8000 app:init_func

My app.py file:

def init_func(argv):
    app = web.Application(middlewares=[aiohttp_error_middleware])
    app.router.add_post("/api/messages", messages)
    return app
if __name__ == "__main__":
    app = init_func(None)

    try:
        web.run_app(app, host="0.0.0.0", port=CONFIG.PORT)
    except Exception as error:
        raise error

**The Error I am getting is **

2021-06-07T14:15:21.045987180Z aiohttp.web: error: unable to import main: No module named 'app'

I referred following answers from stackoverflow, but it doesn't work for me

  1. How to Deploy MS Botframework in Python to Azure
  2. Running an Python App as an Azure Web App

Also referred the Microsoft documentation:

  1. https://learn.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask
  2. https://learn.microsoft.com/en-gb/azure/app-service/configure-language-python
  3. https://learn.microsoft.com/en-gb/azure/app-service/configure-language-python#modulenotfounderror-when-app-starts
  4. https://learn.microsoft.com/en-us/azure/developer/python/tutorial-deploy-app-service-on-linux-04

I am stuck in deploying this bot to Azure for a week now. Any help/pointers/suggestions is much appreciated.

Thanks in advance.

7
  • Did you checked here : youtube.com/watch?v=1w7UT_wx-tk Commented Jun 8, 2021 at 13:29
  • Yes i did. Yours was the first video that I referred. But, its not working for me. I followed your video step-by-step instead of uploading the code through GitHub, I am using VSCode extension for Azure App Service. Commented Jun 8, 2021 at 15:57
  • I tried your EchoBot code from the link - github.com/rvinothrajendran/BotTutorialSample/tree/master/… And it worked in emulator and following the same steps when I deployed it to webapp it is giving me error - 1. Failed to find attribute 'app' in 'app'. startup - gunicorn --bind=0.0.0.0 --timeout 600 app:appstartup - gunicorn --bind=0.0.0.0 --timeout 600 app:init_func() 2. TypeError: init_func() takes 1 positional argument but 2 were given 3. TypeError: __call__() takes 1 positional argument but 3 were given Commented Jun 8, 2021 at 22:38
  • Are you really using python3.7 as a command rather than python or py or py -3.7? I've never seen that before. You say you're using VS Code for deployment but the documentation you linked to doesn't mention VS Code. How are you using that documentation? One of the documents you linked to clearly explains that the error you're seeing is most likely caused by erroneously deploying a virtual environment. Have you verified that you're not deploying a virtual environment by checking the code in your app service? Please be more descriptive about what's happening than saying "it's not working" Commented Jun 9, 2021 at 21:55
  • I have a similar problem - trying to deploy a simple bot written in c# (with MS Bot Framework) into a Linux-based App Service. So far no luck. Can't even find if its possible Commented Jun 9, 2021 at 23:33

1 Answer 1

0

Some restrictions to create app id and password in your student azure account, try to check without app id and password

hope it will work.

Sign up to request clarification or add additional context in comments.

1 Comment

This worked for me using ngrok. Thank you Vinoth Rajendran for all the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.