GithubHelp home page GithubHelp logo

azure-app-service / python Goto Github PK

View Code? Open in Web Editor NEW
54.0 54.0 78.0 99 KB

base image for Python on linux app service

License: Apache License 2.0

Shell 17.88% Python 50.08% HTML 24.08% Dockerfile 7.96%

python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python's Issues

invalid argument "/python:3.7_1912040917" for "-t, --tag" flag: invalid reference format

to whom it may concern,

I receive the following error message when I run build.sh

QUESTION: any idea?

QUESTION: how to build the dockerfile?

the error message

/python/3.7 (master)
$ ./build.sh
++ date -u +%y%m%d%H%M

  • buildnumber=1912040917
  • docker build --no-cache -t /python:3.7_1912040917 . > invalid argument "/python:3.7_1912040917" for "-t, --tag" flag: invalid reference format
    See 'docker build --help'.`

Image broken

The image seems to be missing Python lately. I encountered the following problem when creating a clone of a web app of mine:

2018-10-23T07:45:34.950438211Z 
2018-10-23T07:45:34.950510711Z   _____                               
2018-10-23T07:45:34.950624712Z   /  _  \ __________ _________   ____  
2018-10-23T07:45:34.950641312Z  /  /_\  \___   /  |  \_  __ \_/ __ \ 
2018-10-23T07:45:34.950650813Z /    |    \/    /|  |  /|  | \/\  ___/ 
2018-10-23T07:45:34.950659813Z \____|__  /_____ \____/ |__|    \___  >
2018-10-23T07:45:34.950668913Z         \/      \/                  \/ 
2018-10-23T07:45:34.950677713Z 
2018-10-23T07:45:34.950686113Z A P P   S E R V I C E   O N   L I N U X
2018-10-23T07:45:34.950694613Z 
2018-10-23T07:45:34.950702813Z Documentation: http://aka.ms/webapp-linux
2018-10-23T07:45:34.950711313Z NodeJS quickstart: https://aka.ms/node-qs
2018-10-23T07:45:34.950719713Z 
2018-10-23T07:45:36.767424995Z Starting OpenBSD Secure Shell server: sshd.
2018-10-23T07:45:36.857890131Z Running python /usr/local/bin/entrypoint.py
2018-10-23T07:45:37.933818270Z executing:
2018-10-23T07:45:37.934141573Z python --version
2018-10-23T07:45:37.975129452Z Python 3.7.0
2018-10-23T07:45:37.977691776Z executing:
2018-10-23T07:45:37.982036116Z pip --version
2018-10-23T07:45:38.152536891Z Traceback (most recent call last):
2018-10-23T07:45:38.152620791Z   File "/usr/local/bin/pip", line 7, in <module>
2018-10-23T07:45:38.152632192Z     from pip._internal import main
2018-10-23T07:45:38.152640992Z ModuleNotFoundError: No module named 'pip._internal'
2018-10-23T07:45:38.157763339Z 
2018-10-23T07:45:38.168770241Z found flask app
2018-10-23T07:45:38.169593648Z executing:
2018-10-23T07:45:38.169874151Z . antenv/bin/activate
2018-10-23T07:45:38.175971007Z /bin/sh: 1: .: Can't open antenv/bin/activate
2018-10-23T07:45:38.176351411Z 
2018-10-23T07:45:38.176709014Z executing:
2018-10-23T07:45:38.177021817Z GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn application:app
2018-10-23T07:45:42.009289819Z [2018-10-23 07:45:42 +0000] [38] [INFO] Starting gunicorn 19.9.0
2018-10-23T07:45:42.015367975Z [2018-10-23 07:45:42 +0000] [38] [INFO] Listening at: http://0.0.0.0:8000 (38)
2018-10-23T07:45:42.015735878Z [2018-10-23 07:45:42 +0000] [38] [INFO] Using worker: sync
2018-10-23T07:45:42.051312007Z [2018-10-23 07:45:42 +0000] [41] [INFO] Booting worker with pid: 41
2018-10-23T07:45:45.202130914Z [2018-10-23 07:45:44 +0000] [41] [ERROR] Exception in worker process
2018-10-23T07:45:45.202180014Z Traceback (most recent call last):
2018-10-23T07:45:45.202191114Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-10-23T07:45:45.202219914Z     worker.init_process()
2018-10-23T07:45:45.202230114Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-10-23T07:45:45.202239515Z     self.load_wsgi()
2018-10-23T07:45:45.202248415Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-10-23T07:45:45.202257415Z     self.wsgi = self.app.wsgi()
2018-10-23T07:45:45.202265915Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-10-23T07:45:45.202274915Z     self.callable = self.load()
2018-10-23T07:45:45.202283415Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-10-23T07:45:45.202292515Z     return self.load_wsgiapp()
2018-10-23T07:45:45.202301415Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-10-23T07:45:45.202310315Z     return util.import_app(self.app_uri)
2018-10-23T07:45:45.202318815Z   File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2018-10-23T07:45:45.202327615Z     __import__(module)
2018-10-23T07:45:45.202336015Z   File "/home/site/wwwroot/application.py", line 3, in <module>
2018-10-23T07:45:45.202345316Z     from authlib.flask.client import OAuth
2018-10-23T07:45:45.202353816Z ModuleNotFoundError: No module named 'authlib'
2018-10-23T07:45:45.202892021Z [2018-10-23 07:45:45 +0000] [41] [INFO] Worker exiting (pid: 41)
2018-10-23T07:45:45.410102235Z [2018-10-23 07:45:45 +0000] [38] [INFO] Shutting down: Master
2018-10-23T07:45:45.410492338Z [2018-10-23 07:45:45 +0000] [38] [INFO] Reason: Worker failed to boot.
2018-10-23T07:45:45.561115630Z

Accessing AAD authenticated, logged in user details (e.g. name/email) from deployed app service python web app

Hi,

Specifically for a Python web app (Streamlit framework) deployed as a containerised app service, I need to access details of the AAD authenticated user, such as name and email address. I've tried:

  • the /.auth/me endpoint. Just returns empty list
  • Checking speical headers such as X-MS-CLIENT-PRINCIPAL-NAME and X-MS-CLIENT-PRINCIPAL-ID in the request. Don't exist.

This should be possible. Any guidance appreciated.
Thanks

Unable to install the pyodbc package

We are currently unable to use SQL Server on our Python App Service instance due to an error preventing the install of pyodbc from pip.

    Running setup.py install for pyodbc ... error
    ERROR: Command errored out with exit status 1:
     command: /opt/python/3/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hu419imp/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hu419imp/pyodbc/s
etup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/
pip-record-dl7e4jt2/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-hu419imp/pyodbc/
    Complete output (10 lines):
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    creating build
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.28 -I/opt/python/3/include/python3.7m -c src/buffer.cpp -o build/temp.linux-x86_64-3.7/s
rc/buffer.o -Wno-write-strings
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
Cleaning up...
ERROR: Command errored out with exit status 1: /opt/python/3/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hu419imp/pyodbc/setup.py'"'"'; __file__='"'"'/
tmp/pip-install-hu419imp/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'ex
ec'"'"'))' install --record /tmp/pip-record-dl7e4jt2/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

Image for Python 3.8?

Hi, I'm looking for the repo containing the default docker image for an Azure App Service on linux/python-3.8. Can anybody point me to the right location?

The reason I'm asking: I suspect that the python-3.8 image does not contain nginx anymore, and that the only way to serve static resources (js, css etc.) is to use a WSGI framework that can handle static resources. Would be so awesome if anybody could confirm or clarify this. I've done so much research without getting anywhere, and I'm a bit lost now...
Thank you so much!

Flask app failure happens days after deployment

I have an Azure Linux App Service running with code deployment and Always On: False. The app service works as expected right after deployment, and failed with 503 errors after a certain amount of time. When a 503 error is observed, the stream log from the app service shows the following error message.

2018-11-13 15:24:58.731 INFO  - Starting container for site
2018-11-13 15:24:58.733 INFO  - docker run -d -p 43438:8000 --name usagedriverdevlinux_0 -e WEBSITE_SITE_NAME=usagedriverdevlinux -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=ecd7b7595c2085f900b2a30ce059050e5bc2dcf3927d1ef3f9745e96bd1fef71 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.6.6_1809042203
2018-11-13T15:24:59.092415149Z
2018-11-13T15:24:59.092541749Z   _____
2018-11-13T15:24:59.092546749Z   /  _  \ __________ _________   ____
2018-11-13T15:24:59.092550249Z  /  /_\  \___   /  |  \_  __ \_/ __ \
2018-11-13T15:24:59.092553849Z /    |    \/    /|  |  /|  | \/\  ___/
2018-11-13T15:24:59.092557349Z \____|__  /_____ \____/ |__|    \___  >
2018-11-13T15:24:59.092560949Z         \/      \/                  \/
2018-11-13T15:24:59.092564349Z
2018-11-13T15:24:59.092575449Z A P P   S E R V I C E   O N   L I N U X
2018-11-13T15:24:59.092579649Z
2018-11-13T15:24:59.092582849Z Documentation: http://aka.ms/webapp-linux
2018-11-13T15:24:59.092586049Z NodeJS quickstart: https://aka.ms/node-qs
2018-11-13T15:24:59.092589349Z
2018-11-13T15:24:59.149267270Z Starting OpenBSD Secure Shell server: sshd.
2018-11-13T15:24:59.156074972Z Running python /usr/local/bin/entrypoint.py
2018-11-13T15:24:59.214145894Z executing:
2018-11-13T15:24:59.214256794Z python --version
2018-11-13T15:24:59.218902596Z Python 3.6.6
2018-11-13T15:24:59.219048096Z executing:
2018-11-13T15:24:59.219130396Z pip --version
2018-11-13T15:24:59.666356263Z pip 18.0 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
2018-11-13T15:24:59.679948868Z found flask app
2018-11-13T15:24:59.680570869Z executing:
2018-11-13T15:24:59.680652269Z . antenv3.6/bin/activate
2018-11-13T15:24:59.682776670Z /bin/sh: 1: .: Can't open antenv3.6/bin/activate
2018-11-13T15:24:59.683021870Z
2018-11-13T15:24:59.683119770Z executing:
2018-11-13T15:24:59.683187170Z GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn application:app
2018-11-13T15:24:59.900779151Z [2018-11-13 15:24:59 +0000] [33] [INFO] Starting gunicorn 19.9.0
2018-11-13T15:24:59.901405651Z [2018-11-13 15:24:59 +0000] [33] [INFO] Listening at: http://0.0.0.0:8000 (33)
2018-11-13T15:24:59.901604851Z [2018-11-13 15:24:59 +0000] [33] [INFO] Using worker: sync
2018-11-13T15:24:59.905127153Z [2018-11-13 15:24:59 +0000] [36] [INFO] Booting worker with pid: 36
2018-11-13T15:25:00.082357719Z [2018-11-13 15:25:00 +0000] [36] [ERROR] Exception in worker process
2018-11-13T15:25:00.082389219Z Traceback (most recent call last):
2018-11-13T15:25:00.082394819Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-11-13T15:25:00.082400719Z     worker.init_process()
2018-11-13T15:25:00.082404719Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-11-13T15:25:00.082408919Z     self.load_wsgi()
2018-11-13T15:25:00.082412819Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-11-13T15:25:00.082424919Z     self.wsgi = self.app.wsgi()
2018-11-13T15:25:00.082429119Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-11-13T15:25:00.082433019Z     self.callable = self.load()
2018-11-13T15:25:00.082436819Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-11-13T15:25:00.082440719Z     return self.load_wsgiapp()
2018-11-13T15:25:00.082444419Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-11-13T15:25:00.082448319Z     return util.import_app(self.app_uri)
2018-11-13T15:25:00.082452119Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2018-11-13T15:25:00.082456019Z     __import__(module)
2018-11-13T15:25:00.082459719Z   File "/home/site/wwwroot/application.py", line 6, in <module>
2018-11-13T15:25:00.082464019Z     from flask_httpauth import HTTPBasicAuth
2018-11-13T15:25:00.082467919Z ModuleNotFoundError: No module named 'flask_httpauth'
2018-11-13T15:25:00.082950219Z [2018-11-13 15:25:00 +0000] [36] [INFO] Worker exiting (pid: 36)
2018-11-13T15:25:00.124758235Z [2018-11-13 15:25:00 +0000] [33] [INFO] Shutting down: Master
2018-11-13T15:25:00.125010935Z [2018-11-13 15:25:00 +0000] [33] [INFO] Reason: Worker failed to boot.
2018-11-13T15:25:00.157341247Z
2018-11-13 15:25:01.155 ERROR - Container usagedriverdevlinux_0 for site usagedriverdevlinux has exited, failing site startStatus_WatchFile :: Error Error: ENOENT: no such file or directory, open '/appsvctmp/status.txt'

The problem is solved by switching Always On: True. I suspect that the right virtual environment works right after the deployment. When Always On is turned off, the container is destroyed after a certain amount of time. Then when a new request coming, a container is being created but fails in creating the virtual environment. Then the default Python, who did not install dependencies from requirements.txt, is called. Then ModuleNotFoundError is shown.

By setting Always On to True, the container is always running and the virtual environment created in the container works as well. So that problem is temporary solved.

For more detailed information, please check support ticket [REG:118111321002576]. I really appreciate the help from MSFT support engineers Ramya Gangula and Prashanth Madi in figuring out the possible causes.

Problem having equals ("=") in environment variables values

We tried to have equals in the values of environment variables (for a Redis-generated key that is base64-encoded, but that shouldn't matter), but failed to have the proper value in the running app.

We've managed to pinpoint (at least that's from an external, newbie point-of-view) the issue to the init_container script. The awk is performed with the equal sign ("=") as the field separator, breaking any environment value with this character.

A possible idea would be to do something like this instead:

printenv | awk -F= 'sub("^([^=]+)=", "export "$1"=")'

I'm not an awk expert so I cannot really explain how it works or if it doesn't have any side effect, I just tested it like so on an Ubuntu:

$ export FOO=BAR=

$ printenv |grep FOO
FOO=BAR=

$ printenv | awk -F= '{print "export " $1"="$2 }' | grep FOO
export FOO=BAR

$ printenv | awk -F= 'sub("^([^=]+)=", "export "$1"=")'  | grep FOO
export FOO=BAR=

Python Flask Web App deployment to Azure App Service Issue

Hi Team,

I am trying to deploy my Python 3.8 Flask Web App to a linux Azure App service. I have tried different options for deployment like from Visual Studio Code(using the azure extension), Visual Studio 2019, through PowerShell(for uploading the files to the app service) etc. I can see my files placed in the wwwroot folder on the web app using the Kudu Console. But I am unable to browse my web application. I am still getting the default web page any Azure Web App has. I am able to browse the web app when I run it locally. Could you please help with the issue in deploying my Flask app. PFB some screenshots:

These are the files I have in wwwroot folder:
image

Following is the web page I am getting when I try to browse to the website:
image

Installing python requirements

Should the requirements from requirements.txt be automatically installed when using python3.7 version of the container on my webapp?
Whenever i try to depoly my project, nothing from the requirements.txt gets installed, i had to use a custom startup command to get the app to work

Installing requirements

i'm not convinced with the current approach of installing python modules manually using kudu.
After app restart customers would loose content unless they are stored in /home

Does he have to install Django again after restart manually ?

Python 3.7 missing Django and uwsgi.ini example from tmp

Following the instructions on https://github.com/Azure-App-Service/python#how-to-deploy-django-project
Ran python /usr/local/bin/django-admin.py startproject mysite to start a new project

the command was not found:
root@c7374577c6e3:/# find . -name "django*"
./usr/share/vim/vim80/syntax/django.vim

I had to run:
pip install Django
received the following WARNING: You are using pip version 19.2.1, however version 19.2.3 is available

post, django-admin was available

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.