locked
Migrating Flask web app database on Azure RRS feed

  • Question

  • Hello! so far, everything has been good with the my app deployment and creating a database on Azure. Now, I need to migrate my database for the web app to work successfully but I don't know how to run the database migration command on Azure Cloud shell, bash or CLI. 
    When I try to access the web app, I got "Internal Sever Error" and the error in the app log is:

    [ERROR]  sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "xxxxxxxxx" does not exist

    The Commands I need to run are as follows:
    " flask db init"
    " flask db migrate"  and
    "flask db upgrade"

    Friday, December 20, 2019 12:45 PM

All replies

  • Hi John,

    Your post was moved to Azure Mobile Apps from Cloud Services. We're migrating from MSDN to Microsoft Q&A as our new forums and Azure Web Apps has already made the move!  In future, you can ask and look for the discussion for Azure Web Apps related questions here: https://docs.microsoft.com/answers/topics/azure-webapps.html.
    We are actively working to onboard remaining Azure services on Microsoft Q&A. We will make a public announcement once complete. 
    Want to Learn more about new platform: Microsoft Q&A Getting Started 

    Having said that, could you provide some additional details?

    • The version of python you're using
    • The requirements.txt that you're using
    • The region you're deploying to
    • Are you deploying to windows or linux app service

    Thanks in advance, Ryan

    Monday, December 23, 2019 9:50 PM
  • Python support on Azure App Service for Windows is officially deprecated. Linux is currently the recommended option for running Python apps in App Service.

    You could access (Kudu Console) http://yourwebappname.scm.azurewebsites.net and run those commands from there. Also, you could review and access the debug logs as required from the console. For the running the cmd ensure that you add - <python path> -m flask db init And, also ensure that Flask is installed by that time by using requirements.txt Kindly let us know how it goes for further investigation and share the requested information as Ryan mentioned, we would be more than happy to assist you further.

    As a side note, we did not see a new thread on Microsoft Q&A forum on this topic, feel free to just re-post the question on the Q&A forum as necessary. Thank you for your patience as we evolve the Microsoft Q&A platform.

    Tuesday, January 7, 2020 7:21 PM