0
votes

I have been trying to upload the code from my Django app to Azure. Using multiple methods, it has been failing, with the log messages shown below. The failure seems to relate to the creation of temporary directories by Onyx build. To be transparent, I'm new to both Django and Azure.

First, I worked through the Azure tutorial (link below) and was able to get it working with minimal issues.

https://docs.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app?tabs=bash%2Cclone

When I attempted to follow the same steps (using "webapp up") with my own app, I get the following error message:

Zip deployment failed. {'id': 'XXXXX', 'status': 3, 'status_text': '', 'author_email': 'N/A', 'author': 'N/A', 'deployer': 'Push-Deployer', 'message': 'Created via a push deployment', 'progress': '', 'received_time': '2020-10-21T13:59:11.0137785Z', 'start_time': '2020-10-21T13:59:11.3572791Z', 'end_time': '2020-10-21T13:59:34.2598809Z', 'last_success_end_time': None, 'complete': True, 'active': False, 'is_temp': False, 'is_readonly': True, 'url': 'https://att-informativeness-task.scm.azurewebsites.net/api/deployments/latest', 'log_url': 'https://att-informativeness-task.scm.azurewebsites.net/api/deployments/latest/log', 'site_name': 'att-informativeness-task'}. Please run the command az webapp log deployment show -n att-informativeness-task -g DjangoPostgres-attInform-rg

Running the command they recommend,

az webapp log deployment show -n att-informativeness-task -g DjangoPostgres-attInform-rg

I get:

[ { "details_url": null, "id": "XXXXXX", "log_time": "2020-10-21T13:59:11.2061269Z", "message": "Updating submodules.", "type": 0 }, { "details_url": null, "id": "XXXXXX", "log_time": "2020-10-21T13:59:11.324348Z", "message": "Preparing deployment for commit id '53d578b78c'.", "type": 0 }, { "details_url": null, "id": "XXXXXX", "log_time": "2020-10-21T13:59:11.6729002Z", "message": "Repository path is /tmp/zipdeploy/extracted", "type": 0 }, { "details_url": "https://att-informativeness-task.scm.azurewebsites.net/api/deployments/53d578b78cf941b986537b13d0e6dd06/log/cb3995cc-27c2-4ca7-af9e-f0ca9f2446b7", "id": "XXXXXX", "log_time": "2020-10-21T13:59:11.8452701Z", "message": "Running oryx build...", "type": 2 } ]

In the log file they link, it gives an error similar to that which I get from Bitbucket. As that's pasted below in more readable format, I won't paste it here.

After numerous attempts, I then tried to follow the instructions to push to an Azure directory, as described by the following link (replacing the runtime with "python:3.6").

https://docs.microsoft.com/en-us/azure/developer/javascript/tutorial-vscode-azure-cli-node-04

when running the command

git push azure master

I get the error message:

remote: .......................... remote: Pip install requirements. remote: Invalid requirement: 'asgiref @ file:///tmp/build/80754af9/asgiref_1602513567813/work' remote: Traceback (most recent call last): remote: File "c:\home\site\wwwroot\env\lib\site-packages\pip_internal\req\req_install.py", line 252, in from_line remote: req = Requirement(req) remote:
File "c:\home\site\wwwroot\env\lib\site-packages\pip_vendor\packaging\requirements.py", line 104, in init remote: raise InvalidRequirement("Invalid URL given") remote: pip._vendor.packaging.requirements.InvalidRequirement: Invalid URL given remote: remote: You are using pip version 10.0.1, however version 20.2.4 is available. remote: You should consider upgrading via the 'python -m pip install --upgrade pip' command. remote: An error has occurred during web site deployment. remote: remote: Error - Changes committed to remote repository but deployment to website failed.

(As an aside, my pip version is 20.2.4)

Finally, I tried to link it to a bitbucket repository, as described in the link below.

https://stories.mlh.io/deploying-a-basic-django-app-using-azure-app-services-71ec3b21db08

In the Azure deployment center, it gave a "Failed" status, with the message below.

Command: oryx build /home/site/repository -o /home/site/wwwroot --platform python --platform-version 3.7 -i /tmp/8d875cc3f8eaaa0 -p compress_virtualenv=tar-gz -p virtualenv_name=antenv --log-file /tmp/build-debug.log Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20200917.1, Commit: 59deb778658a124cb74ea8e2c8f39fa87abcc9d9, ReleaseTagName: 20200917.1

Build Operation ID: |65ZW7nGEe38=.2744c71e_ Repository Commit : fa4d6bc9674997d6c32b0dd6ffc32c29c4364488

Detecting platforms... Detected following platforms: python: 3.7.9 Warning: An outdated version of python was detected (3.7.9). Consider updating.\nVersions supported by Oryx: https://github.com/microsoft/Oryx

Using intermediate directory '/tmp/8d875cc3f8eaaa0'.

Copying files to the intermediate directory... Done in 1 sec(s).

Source directory : /tmp/8d875cc3f8eaaa0 Destination directory: /home/site/wwwroot

Python Version: /opt/python/3.7.9/bin/python3.7 Python Virtual Environment: antenv Creating virtual environment... Activating virtual environment... Running pip install... [14:19:18+0000] Collecting appnope==0.1.0 [14:19:18+0000] Downloading appnope-0.1.0-py2.py3-none-any.whl (4.0 kB) ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build/80754af9/asgiref_1602513567813/work' [14:19:18+0000] Processing /tmp/build/80754af9/asgiref_1602513567813/work

WARNING: You are using pip version 20.1.1; however, version 20.2.4 is available. You should consider upgrading via the '/tmp/8d875cc3f8eaaa0/antenv/bin/python -m pip install --upgrade pip' command. ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build/80754af9/asgiref_1602513567813/work'\n\nWARNING: You are using pip version 20.1.1; however, version 20.2.4 is available.\nYou should consider upgrading via the '/tmp/8d875cc3f8eaaa0/antenv/bin/python -m pip install --upgrade pip' command.\n/opt/Kudu/Scripts/starter.sh oryx build /home/site/repository -o /home/site/wwwroot --platform python --platform-version 3.7 -i /tmp/8d875cc3f8eaaa0 -p compress_virtualenv=tar-gz -p virtualenv_name=antenv --log-file /tmp/build-debug.log

For all of these, it seems the issue centers on creating and accessing tmp directories. It's weird because the process worked with the Azure tutorial code. I tried to bring my own code in line with the example by the creation of files like "production.py" and "settings.txt," changing variables in my "settings.py" file, as well as following the recommendations after running,

python manage.py check --deploy

Really any suggestions would be welcome. Thanks!

1

1 Answers

0
votes

Figured out what was going on. Thought I would post the answer here in case any other newbie runs into the same issue.

The problem was in the requirements.txt file. I had used the command,

pip freeze > requirements.txt 

then didn't go through the results. Turns out there were a number of packages with an "@file..." to the right. Those were causing the errors. I just deleted the "@file..." and replaced it with a specific version for the package.

Also, make sure you specify that psycopg is the binary, using.

psycopg2-binary==2.8.6