- Published on
Deploy Python Echo Bot to Azure App Service on Linux for Azure Bot Service
- Authors
- Name
- Naito Oshima
Overview
The article is an instructions on how to deploy Bot application based on Python Bot Framework SDK via Visual Studio Code and create new Azure Bot resource on Azure Portal.
Sample : Echo Bot Sample using Python Bot Framework SDK
1. Create Azure Bot resource
Create a resource called Azure Bot by following steps 1 through 9 in "Creating an Azure Bot Resource" below. However, I'll introduce "multi-tenant app" of AAD application object in the following article.
Creating a bot using Azure Bot Service - Bot Service | Microsoft Docs
From the left "Configuration" panel on the created Azure Bot resource, check Micosoft App ID.
And, you need to create new password for Azure AD application registration.
2. Create Azure App Service on Linux resource and set configurations
Create App Service on Linux, and then set newest Python : 3.x in advance.
ref.) Quick Start : Creating a Python app in Azure portal - Azure App Service | Microsoft Docs
After creating the App Service on Linux resource, click "Configuration" in the left panel of the above App Service on Linux resource.
In the Configuration page, under Application Settings, click "+ New Application Settings" to create a new one.
- Input MicrosoftAppId in Name and the value you checked "as Micosoft App ID" above.
- Click "+ New Application Settings" again and set MicrosoftAppPassword as "Name" and the value to Azure AD application registration secret password you created above.
In the same way, in the "Configuration", "General Settings" tab, enter the following command in the "Startup Commands" field
gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
3. Configure Azure Bot endpoint information
Copy the URL in the Overview panel of the Azure App Service on Linux resource.
You should set "HTTPS URL of App Service on Linux + /api/messages/" to the Messaging Endpoint on "Configuration" blade of Azure Bot Service resource.
4. Check Python Echo Bot in your local environment
Download from the following GitHub repository and open botbuilder-samples\samples\python\02.echo-bot. In the \02.echo-bot folder, run "pip install -r requirements.txt" as described in the following reference at the command prompt to install the module. After installing the module, run the Echo bot (Python) from a command prompt using python app.py in the same way.
ref.) Echo Bot Sample using Python Bot Framework SDK
Open the folder \02.echo-bot in your local environment using Visual Studio Code (VS Code).
If VS Code does not already have the Azure App Service extension, or if you are not signed in to your Azure account in the extensions panel, please do those beforehand.
5. Deploy Echo Bot to App Service on Linux
Follow the steps below to deploy the above Python Echo Bot to the App Service on Linux that you have already created.
A. Login to your Azure account at Sign in to Azure in the App Service section of VS Code's App Service extension.
B. Right click on the App Service on Linux resource created above and select "Deploy to Web App"
C. Check the folder of the relevant Echo bot (Python) project you wish to deploy
6. Test the Azure Bot Resource Web Chat to make sure it works.
After deploying the above, verify that it works by testing it in the Web Chat section of the Azure Bot Resource.
If it does not work, leave a little time and try again by reloading the top "Start over" or the screen itself.