hamzah jazi
hamzah jazi

Reputation: 55

Container test_0_4cb91f00 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging

I'm trying to deploy Echo bot from microsoft samples of botframework to azure web app (python) and Whenever i try to test it after a successful deployment an error appears says

Initiating warmup request to container test_0_fea5f125 for site test 2023-11-09T09:25:00.574Z ERROR - Container test_0_fea5f125 for site test has exited, failing site start 2023-11-09T09:25:00.607Z ERROR - Container test_0_fea5f125 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

I've tried to deploy the .net Echo bot to azure web app and it's working perfectly but the python one doesn't, and i tried to add the WEBSITES_PORT = 8000 in azure web app configuration and still got the same error.

https://i.sstatic.net/t1l8j.png

Upvotes: 0

Views: 1095

Answers (2)

user23327181
user23327181

Reputation: 1

If you are deploying using a zip file, when creating the ZIP package for deployment, don't include the root directory, but only the files and directories in it. It took me a while to deploy my echo bot, and the error was due the way I was creating the zip file. More info here: https://learn.microsoft.com/en-us/azure/app-service/deploy-run-package

# Bash
zip -r <file-name>.zip .

# PowerShell
Compress-Archive -Path * -DestinationPath <file-name>.zip

Upvotes: 0

Pravallika KV
Pravallika KV

Reputation: 8579

Follow the below steps to create and deploy Echo Bot to Azure App Service.

  • Referred MSDOC and created an Echo Bot application with the command:
cookiecutter https://github.com/microsoft/BotBuilder-Samples/releases/download/Templates/echo.zip

Bot Framework Emulator response in local:

enter image description here

  • Modify the below code in app.py
app = web.Application(middlewares=[aiohttp_error_middleware])
app.router.add_post("/api/messages", messages)

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

Instead, add the below code taken from SO.

  • Thanks @jackygeee for the code:
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

UPDATED SOLUTION:

requirements.txt:

botbuilder-integration-aiohttp>=4.14.0
aiohttp
botbuilder-core
botbuilder-schema
  • Create and activate virtual environment in local by running the below commands:
python -m venv env
env\Scripts\activate

enter image description here


  • Create Azure Bot and Azure App Service:
  • Go to Azure Bot=> Configuration, paste your web app's URL by adding /api/messages(https://<webapp_name>.azurewebsites.net/api/messages) in the Messaging EndPoint.
  • Copy Microsoft App ID value.
  • Click on Manage Password in the configuration, create new secret and copy its value (which will be used as Microsoft App password in the code).

enter image description here

  • Created a secret to use its value as my Application password:

enter image description here

  • Go to Config.py in your Echo Bot project and paste the App_ID and App_Password which were copied as mentioned above.
import os
class DefaultConfig:
    """ Bot Configuration """

    PORT = 3978
    APP_ID = os.environ.get("MicrosoftAppId", "<Your_App_ID>")
    APP_PASSWORD = os.environ.get("MicrosoftAppPassword", "<Your_App-Password")
  • Deploy the application to Azure App Service:

enter image description here

After deploying the application to Azure:

  • Navigate to your web app=>Settings=> Configuration =>General Settings=> Startup Command, add the command:
python3 -m aiohttp.web -H 0.0.0.0 -P 8000 app:init_func

enter image description here

  • Go to your Azure Bot =>Settings=>Test in Web Chat and test the chat:

enter image description here

Upvotes: 1

Related Questions