[Python] I'm trying to deploy a python app to azure but it doesn't work even with a quickstart...

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    Here's an article from Microsoft with a quickstart guide for python app at azure. So I'm trying to deploy a python app on azure using free tier but it simply doesn't work. I've tried multiple things already. I've cloned sample project code from here as the article suggests. Then I've tried to run it locally using python 3.12. That version is the latest supported for an azure web app at the moment. It works locally on my pc even though /admin/ doesn't work there, but whatever: at least some page opens successfully. I've ran it via pycharm community with a virtual environment. Then I've tried to upload these folders and files to the site/wwwroot folder:

    folder:
    .venv
    hello_azure
    quickstartproject
    static
    .env.sample
    db.sqlite3
    manage.py
    requirements.txt


    Before doing that I've created a web app on free tier, chose python 3.12 and opened public access to the website. In the overview of the app it's running. I've also tried to add as a startup command these: manage.py runserver, site/wwwroot/manage.py runserver, python manage.py runserver, python site/wwwroot/manage.py runserver, but non of that worked. On attempt to open the website it shows this error:

    :( Application Error
    If you are the application administrator, you can access the
    diagnostic resources.


    Dev Tools, Network tab shows 503 error. When I go to those "diagnostic resources" following the provided link it says "Resource not found. Status Code: 404. Status Message: unavailable" (there's more text there but this seems to be the most significant). BUT! This resource exists and my web app has status "Running". Also I've tried to restart it after some changes made multiple times and wait for few minutes thinking that probably it just needs like 5 minutes to start working as it's happening with .NET applications after release. But it doesn't help.

    At first I've tried that with my target website that I'm actually trying to deploy. Then I've decided to try just a minimalistic proof of concept approach with a provided sample. But it didn't work neither.

    Log stream has a lot of text. One of last messages that caught my attention was this one: Container {container-name} didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

    Log files, found via filezilla in the folder "LogFiles" have a ton of messages, but nothing that seems to be informative. Just a bunch of generic messages like "starting website, unexpected exception, couldn't start a container, stopping website due to exception". Not exect logs, but there's something like that. Also there's a command docker run -d --expose=8000 --name {application-name} -e WEBSITE_USE_DIAGNOSTIC_SERVER=false -e.

    ALLOWED_HOSTS contains the domain for my website where I'm trying to host my code. I've even tried as a test to just leave it ALLOWED_HOSTS = [], which should allow any host, but it didn't help, so that's definitely not an issue here. I've updated that in the file production.py.

    SSH console also doesn't work for some reason. It just shows an error message "SSH CONN CLOSED". So no available actions there neither.

    So currently I'm just totally confused and out of ideas regarding how to make this [censored] to work. It's definitely either me doing something wrong or azure doesn't provide a working hosting for python apps (at least in free version). In most cases like that it's about a developer. So maybe something still can be done? Any ideas and/or suggestions on what's going on, why and how to fix it?

    P.S. At the moment my goal is to host it on azure for free without spending a single cent. If I understood correctly, that should be possible on azure. At the moment my website is hosted for free at pythonanywhere.com, but it requires manual renewal of a website from time to time. So I thought of attempt to move to azure.

    Continue reading...

Compartilhe esta Página