Forum Discussion

ananthuraj's avatar
ananthuraj
Copper Contributor
Jun 07, 2023

Python Flask app for ChatBot not working Properly in Azure Webapp

I have created a python flask framework app which creates a basic chatbot using azure openai llm and embeddings. This uses an index.html template and the site loads and the chat responses work as expected in my local. 
But when I deploy it to webapp (Basic Plan, python 3.10), the site loads and the structure is fine but the chat functionality is not working. All packages are mentioned in the requirements file and during deployment the packages are installed properly automatically. 
Just for one time, i was able to make this work and i have that repo as a backup. But when i tried with the exact repo again, its not working.
Has anyone else faced similar issues ?

My guess is the way the frontend connects with the flask app has issues. The site loads but the flask code is not being accessed. If anyone can help with this, it would be great. 

 

 

7 Replies

  • azharamir13's avatar
    azharamir13
    Brass Contributor
    Check error logs: Enable and review the error logs for your Azure Web App. You can access the logs through the Azure Portal or use tools like Azure CLI or Azure PowerShell. Reviewing the error logs can provide insights into any specific errors or exceptions occurring during deployment.

    Verify package versions: Ensure that the packages and dependencies listed in your requirements file are compatible with the Python version used by Azure Web App (3.10 in your case). Check for any package versions that might cause conflicts or compatibility issues. It's also a good practice to pin the versions of the packages you are using to avoid unexpected updates.

    Review configuration: Double-check the configuration settings in your Azure Web App. Verify that environment variables, paths, and other settings required by your Flask app are correctly configured in the Azure Web App environment.

    Check deployment steps: Compare the deployment steps you followed when the chat functionality was working with the steps you followed when it failed. Ensure that all the necessary files, scripts, and configurations are included and properly deployed to Azure Web App.

    Test in local development environment: Create a local development environment that closely matches the Azure Web App environment (e.g., Python 3.10) and test your Flask app there. This will help you identify if any specific differ
    • ananthuraj's avatar
      ananthuraj
      Copper Contributor

      azharamir13 Thanks for the response.

      Update : I did try out some of the options you mentioned and the app worked with the chat feature.

      But now the issue is, the site will only work for somw time and then it becomes unresponsive. When i go to azure portal and restart the app service it works but thats also not garunteed all the time. Im still using the B1 resource for the app service.

      Is there anything that can be done to improve the availability and reliability of the deployed website ?

      • azharamir13's avatar
        azharamir13
        Brass Contributor
        Mark answer as like if it helps

        Upgrade the App Service Plan: Consider upgrading your App Service Plan to a higher tier with more resources, such as CPU, memory, and network bandwidth. The B1 resource may have limited resources, which could be causing the unresponsiveness. Scaling up to a higher tier can provide more capacity for your application to handle increased traffic or resource demands.

        Enable Application Insights: Application Insights is an Azure service that helps monitor and diagnose issues in your web application. Enable Application Insights for your Azure Web App to gain insights into the performance, availability, and usage of your application. It can provide telemetry data, metrics, and logs to help troubleshoot and identify any performance bottlenecks or errors.
        Implement Caching: Utilize caching mechanisms, such as in-memory caching or distributed caching, to reduce the load on your backend services and improve response times. Caching can help store frequently accessed data or expensive computations, reducing the need to retrieve or compute them repeatedly.

Resources