1

I have a simple Azure WebJob written in Python that utilizes the azure python package (which is located in a venv within my solution). The job executes as expected on my local machine, but when I deploy it to the Azure WebJob instance, I get the following error:

ImportError: No module named azure.storage.table

The actual .py is as follows:

from azure.storage.table import TableService

# get table service
table_service = TableService(account_name='myacct', account_key='mykey')

# delete table
table_service.delete_table('MyTable')

How can I access the azure package from the WebJob instance?

2 Answers 2

2

By default, if you leverage venv in your python application on Azure Web apps, after you deploying your web app to Azure, the venv folder will locate in D:\home\site\wwwroot\env\. And also the python libraries will lie at D:\home\site\wwwroot\env\Lib\site-packages. You can install the python libs in your web app and leverage this absolute address in your python web job scripts, to load the libs in your python web application.

Please try the following test script in WebJobs:

import sys
sitepackage = "D:\home\site\wwwroot\env\Lib\site-packages"
sys.path.append(sitepackage)

try:
    from azure.storage.table import TableService
    print "successfully load lib"
except ImportError, e:
    print "cannot load lib"
Sign up to request clarification or add additional context in comments.

2 Comments

The underlying web app is an ASP.NET WebApi. I'm assuming that your answer is only applicable to Python based web apps in Azure.
The general idea is the same even if you only use python env in webjob. You can generate a python env with your libs (similar to azure.microsoft.com/en-us/documentation/articles/…), and package the env with your python webjob script, modify the sitepackage to the relative path as env\Lib\site-packages, deply to Azure WebJobs together.
0

The only solution I found currently is to push yourself the packages. This might help you:

http://nicholasjackson.github.io/azure/python/python-packages-and-azure-webjobs/

2 Comments

The link is not live any more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.