Search code examples
python-3.xazureazure-web-app-serviceazure-webjobsazure-webjobssdk

Webjobs Running Error (3587fd: ERR ) from zipfile


I have the following small script in a file named fgh.py which I have been attempting to schedule as a webjob

import pandas as pd

df=pd.DataFrame({'a':[1,2,2],'b':[5,6,9]})

df['x']=df.a.sub(df.b)

print(df)

Using @Peter Pan post. I have created a virtual environment, done a pip install pandas. From the virtual environment, the script runs and executes as required.It however does not execute when loaded in Azure Webjobs. I suspect issues arise from the interface between the run,bat file and the Azure python console but have limited understanding of Azure to resolve the issue

In kudus, I have used this post to install python.

Running where python in cmd command in https://myapp.scm.azurewebsites.net/DebugConsole I get;

enter image description here

Additionally from https://arcgistrial.scm.azurewebsites.net/DebugConsole I get the following when I run cmd command python -V enter image description here

In my run.bat file, I have tried to use either of the directories above without success.

Whether I make my run.bat file D:\home\python364x64\python.exe fgh.py or D:python364x64\python.exe fgh.py I get the following error; enter image description here

I have gone a head and installed pandas and checked if successful by trying to install numpy enter image description here

All this has not helped. I have been on this for a couple of days and it has to work somehow. Any help?


Solution

  • (Things are not quite straightforward in old Webjobs to run python task with dependencies. It has been quite some time, the world has moved on to Azure Function :))

    However, since you still need to stick to Webjobs, below are the steps I followed which worked. I am using a batch file (.cmd) to run the python script due to the pre-requisites.

    1. By default webjob supports python 2.7 at this moment. So, add python3 from 'extension' in your web app, In this case it was 3.6.4 x64 for me. This will add in path D:\home\python364x64\. How did I know? Kudus console :)

    enter image description here

    1. Create a requirements.txt file which contains pandas and numpy (note I had to explicitly add numpy version 1.19.3 due to an issue with latest 1.19.4 in Windows host at the time of this writing). Basically I used your fgh.py which depends on pandas which in turn depends on numpy.
    pandas==1.1.4
    numpy==1.19.3
    
    1. Create a run.cmd file having the following content. Note 1st line is not needed. I was just checking python version.
    D:\home\python364x64\python --version
    D:\home\python364x64\python -m pip install --user --upgrade pip
    D:\home\python364x64\python -m pip install --user certifi
    D:\home\python364x64\python -m pip install --user virtualenv
    D:\home\python364x64\python -m virtualenv .venv
    .venv\Scripts\pip install -r requirements.txt
    .venv\Scripts\python fgh.py
    
    1. Zip fgh.py, run.bat and the requirements.txt files into a single zip. Below is the content of my zip.

    enter image description here

    1. Upload the zip for the webjob.
    2. Run the job :)

    enter image description here enter image description here

    Ignore the error "ModuleNotFoundError: No module named 'certifi'", not needed.