Blog Post

IIS Support Blog
1 MIN READ

A quick guide to publish Python SDK Azure Bots in App Service

Shekhar's avatar
Shekhar
Icon for Microsoft rankMicrosoft
Oct 23, 2022

This article assumes that you already have created and published Python Bot using the link below:

Provision and publish a bot in Azure - Bot Service | Microsoft Learn

 

But you might end up facing some issues like below:

  • Container pythonbot_### didn't respond to HTTP pings on port: 8000, failing site start
  • Container pythonbot_### for site pythonbot has exited, failing site start
  • Failed to find attribute 'app' in 'app'.

Probable causes:

App Service configured as Messaging Endpoint could have been missing one or more of the following configurations:

 

  1. App Service --> Configuration --> Application Settings:
    1. MicrosoftAppId (Application Id of the App Registration)
    2. MicrosoftAppPassword (Secret of the App Registration if not ManagedIdentity type)
    3. SCM_DO_BUILD_DURING_DEPLOYMENT: true (build during deployment to true)

  2. App Service --> Configuration --> General Settings: You need to provide a startup command that will be run as part of container startup, you can use the following : 
    gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:<APP​>

     


     

    Note : <APP> should be application's root file. By default it is APP is root file name. 

The following article talks in detail about startup command for Python in Azure App Service : 

Configure Linux Python apps - Azure App Service | Microsoft Learn

I hope this helps. 

Published Oct 23, 2022
Version 1.0
  • Thanks Shekhar. We may need to add the gunicorn package to requirements.txt if you see below error:

     

    2024-06-11T00:29:26.983771768Z File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
    2024-06-11T00:29:26.983776468Z File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
    2024-06-11T00:29:26.983808268Z File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
    2024-06-11T00:29:26.983813668Z File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
    2024-06-11T00:29:26.983818268Z File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
    2024-06-11T00:29:26.983822768Z File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
    2024-06-11T00:29:26.983827468Z ModuleNotFoundError: No module named 'aiohttp'

    aiohttp is actually should be installed if we have botbuilder-integration-aiohttp package installed. But the default installation of gunicorn might not recognize the packages installed by the build system, hence needs to be installed during build (using requirements.txt)