Azure Deployment

98 views
Skip to first unread message

Tony Zgraggen

unread,
Jan 22, 2021, 5:41:22 PM1/22/21
to Jam.py Users Mailing List
Hi I am new in these group and I tried to deploy a running application (localhost and also PythonAnywhere) in AZURE but I didn't get it running. Has anybody experience with deployment to AZURE?

Dražen Babić

unread,
Jan 22, 2021, 8:40:36 PM1/22/21
to Jam.py Users Mailing List
Hi,

It is easy as 1,2,3....

Explained on FB group.

Cheers

D.

On Sat, 23 Jan 2021, 06:41 Tony Zgraggen, <puc...@gmail.com> wrote:
Hi I am new in these group and I tried to deploy a running application (localhost and also PythonAnywhere) in AZURE but I didn't get it running. Has anybody experience with deployment to AZURE?

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/defacd8c-b4ef-44af-ba91-b4ca94eccf49n%40googlegroups.com.

Richard Azevedo

unread,
Jan 25, 2021, 2:51:38 PM1/25/21
to Jam.py Users Mailing List
Hi, can somebody publish this explain here, please ? (for who doesn't have FB account).

Tony Zgraggen

unread,
Jan 25, 2021, 3:28:38 PM1/25/21
to Jam.py Users Mailing List
Basically what I found on the Facebook Group (FB Group) was following:

In Settings - Configuration/General Settings/Startup Command  put the command
mv admin.sqlite /tmp/.; ln -s /tmp/admin.sqlite .; gunicorn --bind=0.0.0.0 --timeout 600 wsgi

or put this command in a file ex. startup.txt and put the filename startup.txt in   Settings - Configuration/General Settings/Startup Command

I tried it but it didn't help me, but probably I still have another problem I am not aware of.

Regards
Anton

Dražen Babić

unread,
Jan 25, 2021, 8:37:20 PM1/25/21
to Jam.py Users Mailing List
Hi,

the "Azure Deployment" subject is a bit misleading.

The Facebook post touched deployment as an Web App Service, and such a service is read only file system. Unless, 2 years after, MS somehow enabled write access to file system, it is impossible to run anything which needs write access.

Hence, the hack was to move admin.sqlite to /tmp folder, which has write access. However, over time, Jam got other r/w files. 

So, Azure Delpoyment as Web Service I think needs some attention by MS ;)

D.

Tony Zgraggen

unread,
Jan 27, 2021, 1:23:48 PM1/27/21
to Jam.py Users Mailing List
Hi 

After deployment of the code from a local git to the azure it still doesn't doesn't startup but there is a new error rising. Don't know if its connected to r/w rights.
Below the log with the current error.

2021-01-27T18:06:12.515023232Z 
2021-01-27T18:06:12.515049635Z   _____                               
2021-01-27T18:06:12.515055235Z   /  _  \ __________ _________   ____  
2021-01-27T18:06:12.515059236Z  /  /_\  \___   /  |  \_  __ \_/ __ \ 
2021-01-27T18:06:12.515070537Z /    |    \/    /|  |  /|  | \/\  ___/ 
2021-01-27T18:06:12.515074637Z \____|__  /_____ \____/ |__|    \___  >
2021-01-27T18:06:12.515078738Z         \/      \/                  \/ 
2021-01-27T18:06:12.515082738Z 
2021-01-27T18:06:12.515086338Z A P P   S E R V I C E   O N   L I N U X
2021-01-27T18:06:12.515090339Z 
2021-01-27T18:06:12.515093839Z Documentation: http://aka.ms/webapp-linux
2021-01-27T18:06:12.515097639Z Python 3.8.6
2021-01-27T18:06:12.515102840Z Note: Any data outside '/home' is not persisted
2021-01-27T18:06:12.796629343Z Starting OpenBSD Secure Shell server: sshd.
2021-01-27T18:06:13.366729480Z Site's appCommandLine: startup.txt
2021-01-27T18:06:13.367320541Z Checking of startup.txt is a file
2021-01-27T18:06:13.369333950Z App command line is a file on disk
2021-01-27T18:06:13.390097504Z startup.txt file exists on disk, reading its contents to run as startup arguments
2021-01-27T18:06:13.399376067Z Contents of startupScript: mv admin.sqlite /tmp/.; ln -s /tmp/admin.sqlite .; gunicorn --bind=0.0.0.0 --timeout 600 wsgi
2021-01-27T18:06:13.399395669Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'mv admin.sqlite /tmp/.; ln -s /tmp/admin.sqlite .; gunicorn --bind=0.0.0.0 --timeout 600 wsgi'
2021-01-27T18:06:13.496985292Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2021-01-27T18:06:13.500918600Z Build Operation ID: |sxj3A96qSQg=.378771bd_
2021-01-27T18:06:13.567061461Z Oryx Version: 0.2.20201112.1, Commit: a120bb248aa8d208ca5e02d7d9d075196e79cffd, ReleaseTagName: 20201112.1
2021-01-27T18:06:14.977360250Z Writing output script to '/opt/startup/startup.sh'
2021-01-27T18:06:15.402224620Z Found virtual environment .tar.gz archive.
2021-01-27T18:06:15.402926193Z Removing existing virtual environment directory /antenv...
2021-01-27T18:06:15.491559087Z Extracting to directory /antenv...
2021-01-27T18:06:18.050631227Z Using packages from virtual environment antenv located at /antenv.
2021-01-27T18:06:18.051343500Z Updated PYTHONPATH to ':/antenv/lib/python3.8/site-packages'
2021-01-27T18:06:20.150617147Z [2021-01-27 18:06:20 +0000] [43] [INFO] Starting gunicorn 20.0.4
2021-01-27T18:06:20.151964987Z [2021-01-27 18:06:20 +0000] [43] [INFO] Listening at: http://0.0.0.0:8000 (43)
2021-01-27T18:06:20.152582651Z [2021-01-27 18:06:20 +0000] [43] [INFO] Using worker: sync
2021-01-27T18:06:20.177443228Z [2021-01-27 18:06:20 +0000] [45] [INFO] Booting worker with pid: 45
2021-01-27T18:06:27.648720180Z [2021-01-27 18:06:27 +0000] [45] [ERROR] Exception in worker process
2021-01-27T18:06:27.648769685Z Traceback (most recent call last):
2021-01-27T18:06:27.648776086Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-01-27T18:06:27.648781486Z     worker.init_process()
2021-01-27T18:06:27.648785987Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2021-01-27T18:06:27.648790987Z     self.load_wsgi()
2021-01-27T18:06:27.648795488Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2021-01-27T18:06:27.648800288Z     self.wsgi = self.app.wsgi()
2021-01-27T18:06:27.648804589Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-01-27T18:06:27.648815090Z     self.callable = self.load()
2021-01-27T18:06:27.648819790Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2021-01-27T18:06:27.648824391Z     return self.load_wsgiapp()
2021-01-27T18:06:27.648828691Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2021-01-27T18:06:27.648834792Z     return util.import_app(self.app_uri)
2021-01-27T18:06:27.648839292Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2021-01-27T18:06:27.648843893Z     mod = importlib.import_module(module)
2021-01-27T18:06:27.648848193Z   File "/opt/python/3.8.6/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-01-27T18:06:27.648852694Z     return _bootstrap._gcd_import(name[level:], package, level)
2021-01-27T18:06:27.648857094Z   File "", line 1014, in _gcd_import
2021-01-27T18:06:27.648861995Z   File "", line 991, in _find_and_load
2021-01-27T18:06:27.648866495Z   File "", line 975, in _find_and_load_unlocked
2021-01-27T18:06:27.648870996Z   File "", line 671, in _load_unlocked
2021-01-27T18:06:27.648875396Z   File "", line 783, in exec_module
2021-01-27T18:06:27.648879896Z   File "", line 219, in _call_with_frames_removed
2021-01-27T18:06:27.648884397Z   File "/home/site/wwwroot/wsgi.py", line 4, in 
2021-01-27T18:06:27.648888997Z     application = create_application(__file__)
2021-01-27T18:06:27.648893198Z   File "/antenv/lib/python3.8/site-packages/jam/wsgi.py", line 108, in create_application
2021-01-27T18:06:27.648897598Z     application = App(work_dir, load_task)
2021-01-27T18:06:27.648901699Z   File "/antenv/lib/python3.8/site-packages/jam/wsgi.py", line 181, in __init__
2021-01-27T18:06:27.648917900Z     create_admin(self)
2021-01-27T18:06:27.648923101Z   File "/antenv/lib/python3.8/site-packages/jam/admin/admin.py", line 53, in create_admin
2021-01-27T18:06:27.648927201Z     task.secret_key = read_secret_key(task)
2021-01-27T18:06:27.648931002Z   File "/antenv/lib/python3.8/site-packages/jam/admin/admin.py", line 27, in read_secret_key
2021-01-27T18:06:27.648934902Z     con.close()
2021-01-27T18:06:27.648938703Z AttributeError: 'NoneType' object has no attribute 'close'
2021-01-27T18:06:27.659040756Z [2021-01-27 18:06:27 +0000] [45] [INFO] Worker exiting (pid: 45)
2021-01-27T18:06:29.416426101Z [2021-01-27 18:06:29 +0000] [43] [INFO] Shutting down: Master
2021-01-27T18:06:29.416941655Z [2021-01-27 18:06:29 +0000] [43] [INFO] Reason: Worker failed to boot.

Drazen D. Babic

unread,
Jan 28, 2021, 3:13:44 AM1/28/21
to Jam.py Users Mailing List
As mentioned, 

try to run Jam on read only file system, and see what happens. Here:

gunicorn wsgi
[2021-01-28 16:11:43 +0800] [12492] [INFO] Starting gunicorn 20.0.4
[2021-01-28 16:11:43 +0800] [12492] [INFO] Listening at: http://127.0.0.1:8000 (12492)
[2021-01-28 16:11:43 +0800] [12492] [INFO] Using worker: sync
[2021-01-28 16:11:43 +0800] [12494] [INFO] Booting worker with pid: 12494
[2021-01-28 16:11:43 +0800] [12494] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/.../lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
.
.

See the error? Same line 583...

Drazen D. Babic

unread,
Jan 28, 2021, 3:39:58 AM1/28/21
to Jam.py Users Mailing List
he he 


... I just claimed the site :)

Drazen D. Babic

unread,
Jan 28, 2021, 10:45:29 PM1/28/21
to Jam.py Users Mailing List
So there u go, 

the site was working perfectly when started, and now is not. So frustrating.

JamAzure.png

Drazen D. Babic

unread,
Jan 29, 2021, 12:48:00 AM1/29/21
to Jam.py Users Mailing List
And now is UP:

2021-01-29T05:44:37.832Z INFO  - Starting container for site
2021-01-29T05:44:37.834Z INFO  - docker run -d -p 9039:8000 --name jampy_0_b5eaf8d9 -e WEBSITE_SITE_NAME=jampy -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=jampy.azurewebsites.net -e WEBSITE_INSTANCE_ID=94a36c26088811151a0293b8f949eda23429828ef41743d274d54f411258035d appsvc/python:3.8_20201112.3 mv admin.sqlite /tmp/.; ln -s /tmp/admin.sqlite .;gunicorn --bind=0.0.0.0 --timeout 600 wsgi
2021-01-29T05:44:37.835Z INFO  - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.

2021-01-29T05:44:40.320Z INFO  - Initiating warmup request to container jampy_0_b5eaf8d9 for site jampy

2021-01-29T05:44:49.706Z INFO  - Container jampy_0_b5eaf8d9 for site jampy initialized successfully and is ready to serve requests.


Can anyone try to access it? Does it work? Because I think after some time it will shutdown and wont work after....

Spyros

unread,
Jan 29, 2021, 2:36:03 AM1/29/21
to Jam.py Users Mailing List
Hi Drazen, 

It does work for me.

Drazen D. Babic

unread,
Jan 29, 2021, 2:58:45 AM1/29/21
to Jam.py Users Mailing List
Thank you for checking.

I will leave this service up over the weekend. You guys have my permission to hit it with all arsenal at your disposal :) It will cost me tho BUT you will see why!

For example, this tool:

is showing below stats when we hit Azure:

JamAzure02.png

And that is not great to use in Production.

So a little warning, we always need Apache or Nginx in front of gunicorn. Gunicorn is not a Web production server. However, how else would one serve Python from Azure App Service?
This is the question for MS.

Here is the HIT graph for above tool:

JamAzure03.png
 
Hope this demonstrates that Jam.py does work on Azure as an App service. How to use it for serious production is another matter ;)

Would be very interesting if we hit this site simultaneously from all over the World :) Any takers? You'll empty my pocket, ha ha

D.

alucabHQ

unread,
Jan 29, 2021, 3:37:11 AM1/29/21
to Drazen D. Babic, Jam.py Users Mailing List
hello,

i have no time to load it, but functionally everything seems to work to me



--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.

Drazen D. Babic

unread,
Apr 12, 2021, 3:37:22 AM4/12/21
to Jam.py Users Mailing List
Hi all, 

just tried today again, and looks very fast when deployed in Central US....This time I configured the Health Check, I wonder if this will prevent the App to go dormant...Not sure why Invoice is not showing tho.
Screenshot from 2021-04-12 15-35-19.png

Drazen D. Babic

unread,
Apr 12, 2021, 3:50:23 AM4/12/21
to Jam.py Users Mailing List
So this was super easy deployment, I just did this from my desktop:

az login
cd jampy-demo/
az webapp up -n jampy

Than I set the startup on General Settings: mv admin.sqlite /tmp/.; ln -s /tmp/admin.sqlite .; gunicorn --bind=0.0.0.0 --timeout 600 wsgi
That's it.

Drazen D. Babic

unread,
Apr 13, 2021, 12:15:27 AM4/13/21
to Jam.py Users Mailing List
So if we want to do the changes, add Azure git to your local, change some file and do "git azure push" providing "Local Git/FTPS credentials" (formated below for posting:

git remote add azure https://Local Git/FTPS credentials @ jampy.scm.azurewebsites.net:443/jampy.git
git push azure masterPassword for 'https://Local Git/FTPS credentials @ jampy.scm.azurewebsites.net:443': 
Counting objects: 259, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (180/180), done.
Writing objects: 100% (259/259), 1.64 MiB | 577.00 KiB/s, done.
Total 259 (delta 67), reused 259 (delta 67)
remote: Resolving deltas: 100% (67/67), done.
remote: Deploy Async
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '08d4d5b95a'.
remote: Repository path is /home/site/repository
remote: Running oryx build...
remote: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
remote: You can report issues at https://github.com/Microsoft/Oryx/issues
remote: 
remote: Oryx Version: 0.2.20210225.2, Commit: f7b557f29a83aa078cc94c0056e7337c07f14271, ReleaseTagName: 20210225.2
remote: 
remote: Build Operation ID: |86SNNMTxANs=.e568eb36_
remote: Repository Commit : 08d4d5b95a1f8f79cefc57e83056e25d12c0232b
remote: 
remote: Detecting platforms...
remote: Detected following platforms:
remote:   python: 3.7.9
remote: Warning: An outdated version of python was detected (3.7.9). Consider updating.\nVersions supported by Oryx: https://github.com/microsoft/Oryx
remote: 
remote: 
remote: Using intermediate directory '/tmp/8d8fe302d4d10ab'.
remote: 
remote: Copying files to the intermediate directory...
remote: Done in 2 sec(s).
remote: 
remote: Source directory     : /tmp/8d8fe302d4d10ab
remote: Destination directory: /home/site/wwwroot
remote: 
remote: Python Version: /opt/python/3.7.9/bin/python3.7
remote: Python Virtual Environment: antenv
remote: Creating virtual environment...
remote: Activating virtual environment...
remote: Running pip install...
remote: [03:57:04+0000] Collecting gunicorn
remote: [03:57:04+0000]   Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
remote: [03:57:04+0000] Requirement already satisfied: setuptools>=3.0 in ./antenv/lib/python3.7/site-packages (from gunicorn->-r requirements.txt (line 1)) (47.1.0)
remote: [03:57:04+0000] Installing collected packages: gunicorn
remote: [03:57:04+0000] Successfully installed gunicorn-20.0.4
remote: WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.
remote: You should consider upgrading via the '/tmp/8d8fe302d4d10ab/antenv/bin/python -m pip install --upgrade pip' command.
remote: Preparing output...
remote: 
remote: Copying files to destination directory '/tmp/_preCompressedDestinationDir'...
remote: Done in 0 sec(s).
remote: Compressing content of directory '/tmp/_preCompressedDestinationDir'...
remote: Copied the compressed output to '/home/site/wwwroot'
remote: 
remote: Removing existing manifest file
remote: Creating a manifest file...
remote: Manifest file created.
remote: 
remote: Done in 9 sec(s).
remote: Running post deployment command(s)...
remote: Triggering recycle (preview mode disabled).
remote: Deployment successful.
 * [new branch]      master -> master

There u go guys, 

fully deployed to Azure even with writable sqlite file. So there is no need for "mv admin.sqlite /tmp/.; ln -s /tmp/admin.sqlite .", MS fixed it. This concludes Azure deployment.

Try it here:

Drazen D. Babic

unread,
Apr 18, 2021, 10:22:21 PM4/18/21
to Jam.py Users Mailing List
Guys,

I completely forgotten, the Azure Application Service (server less Apps), has no means to install LibreOffice, so the report to PDF (or any conversion), would not work.
This would be true for the Amazon Functions etc
PythonAnywhere does have LibreOffice though.

Cheers
Reply all
Reply to author
Forward
0 new messages