简体   繁体   中英

Python script using webjobs in azure

Hello I'm getting an error when uploading a new azure webjob. The error says it cant create the webjob.

I followed this tutorial which I found it in a question that was asked in here. Link

My script is the following:

import sys, os
sys.path.append(os.path.join(os.getcwd(), "site-packages"))
import requests as req

r = req.get('http://my_website.azurewebsites.net/user/cron')
# Development
# r = req.get('http://localhost:5000/user/cron')
print(r.status_code)

And the structure of my files is this one 在此处输入图片说明

If anyone can point out where I made a mistake, I just searched for hours and many questions and tutorials point out this is the proper way to add a library in Azure.

Please refer to the steps as below which I uploaded python script into Webjobs previously.

Step 1 : Use the virtualenv component to create an independent python runtime environment in your system.Please install it first with command pip install virtualenv if you don't have it.

If you installed it successfully ,you could see it in your python/Scripts file.

在此处输入图片说明

Step2 : Run the commad to create independent python runtime environment.

在此处输入图片说明

Step 3: Then go into the created directory's Scripts folder and activate it ( this step is important , don't miss it )

在此处输入图片说明

Please don't close this command window and use pip install <your libraryname> to download external libraries in this command window.

在此处输入图片说明

Step 4:Keep the Sample.py uniformly compressed into a folder with the libs packages in the Libs/site-packages folder that you rely on.

在此处输入图片说明

Step 5: Create webjob in Web app service and upload the zip file,then you could execute your Web Job and check the log

在此处输入图片说明

You could also refer to the SO thread : Options for running Python scripts in Azure

Hope it helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM