Skip to content Skip to sidebar Skip to footer

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['

Solution 1:

(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.


Solution 2:

The key to solving the problem is that you need to create your venv environment on azure.

Step 1. Run successfully in local.

enter image description here

Step 2. Compress your webjob file.

enter image description here

Step 3. Upload webjob zip file.

Because the test environment has python1 before, I will create a webjob of python2 later.

enter image description here

enter image description here

Step 4. Log in kudu.

cd .. enter image description here

② find Python34, click it.

enter image description here

python -m venv D:\home\site\wwwroot\App_Data\jobs\continuous\python2\myenv

enter image description here

④ Find myenv folder.

enter image description here

⑤ active myenv, input .\activate.bat.

D:\home\site\wwwroot\App_Data\jobs\continuous\python2\myenv\Scripts>.\activate.bat

enter image description here

⑥ Back to python2 folder, and input pip install pandas.

enter image description here

⑦ Then input python aa.py.

enter image description here


Post a Comment for "Webjobs Running Error (3587fd: ERR ) From Zipfile"