0
votes

I am trying to read/write from blob storage using a Python WebJob on an Azure App Service. My App Service's requirements.txt file includes the azure-storage package name: the package is successfully installed via pip during App Service deployment. However, when I include the following in my WebJob's run.py file:

import sys
sys.path.append('D:\\home\\site\\wwwroot\\env\\Lib\\site-packages')
from azure.storage.blob import BlockBlobService

...I get the following error message at runtime:

[09/27/2016 17:51:09 > 775106: SYS INFO] Status changed to Initializing
[09/27/2016 17:51:09 > 775106: SYS INFO] Run script 'run.py' with script host - 'PythonScriptHost'
[09/27/2016 17:51:09 > 775106: SYS INFO] Status changed to Running
[09/27/2016 17:51:10 > 775106: ERR ] Traceback (most recent call last):
[09/27/2016 17:51:10 > 775106: ERR ]   File "run.py", line 11, in <module>
[09/27/2016 17:51:10 > 775106: ERR ]     from azure.storage.blob import BlockBlobService
[09/27/2016 17:51:10 > 775106: ERR ]   File "D:\home\site\wwwroot\env\Lib\site-packages\azure\storage\blob\__init__.py", line 15, in <module>
[09/27/2016 17:51:10 > 775106: ERR ]     from .models import (
[09/27/2016 17:51:10 > 775106: ERR ]   File "D:\home\site\wwwroot\env\Lib\site-packages\azure\storage\blob\models.py", line 15, in <module>
[09/27/2016 17:51:10 > 775106: ERR ]     from .._common_conversion import _to_str
[09/27/2016 17:51:10 > 775106: ERR ]   File "D:\home\site\wwwroot\env\Lib\site-packages\azure\storage\_common_conversion.py", line 22, in <module>
[09/27/2016 17:51:10 > 775106: ERR ]     from .models import (
[09/27/2016 17:51:10 > 775106: ERR ]   File "D:\home\site\wwwroot\env\Lib\site-packages\azure\storage\models.py", line 23, in <module>
[09/27/2016 17:51:10 > 775106: ERR ]     from ._error import (
[09/27/2016 17:51:10 > 775106: ERR ]   File "D:\home\site\wwwroot\env\Lib\site-packages\azure\storage\_error.py", line 15, in <module>
[09/27/2016 17:51:10 > 775106: ERR ]     from ._common_conversion import _to_str
[09/27/2016 17:51:10 > 775106: ERR ] ImportError: cannot import name '_to_str'
[09/27/2016 17:51:10 > 775106: SYS INFO] Status changed to Failed
[09/27/2016 17:51:10 > 775106: SYS ERR ] Job failed due to exit code 1

FWIW, several other packages were loaded properly using the same approach. Can anyone suggest a method to get the azure-storage package working in Python Azure WebJobs?

1
if you can't import BlockBlobService, you could try this answer stackoverflow.com/questions/35558463/….johnny
Hi Johnny, I've run into that issue too in the past, but it doesn't seem to be what's going on here.mewahl

1 Answers

1
votes

Looks like six module is missing. This issue is also tracked via this thread: https://github.com/Azure/azure-storage-python/issues/22. You can fix issue by adding the six module to requirements.txt or manually installing six module by pip install six.