question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] azure-storage-blob incompatible with Python Functions 3.8

See original GitHub issue

Investigative information

  • Timestamp: May 14 2020 - 8:40:01 PM PST
  • Function App name: jpwircur7u6mu
  • Exception type Microsoft.Azure.WebJobs.Host.FunctionInvocationException
  • HostInstanceId: d09b7b97-db9e-45c0-857c-2104a0d12a68
  • InvocationId 03abef06-46c7-4243-80f6-36185725f329

Repro steps

  1. Create a function using Python 3.8
  2. Add the import: “from azure.storage.blob import BlobSasPermissions, generate_blob_sas”
  3. Reference any of the storage functions

Similar issue was created here but closed. https://github.com/Azure/azure-sdk-for-python/issues/3623

Expected behavior

There should be no exception

Actual behavior

Will receive the following exception when running the function.

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.MyFunctionName
 ---> Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException: Result: Failure
Exception: ModuleNotFoundError: No module named 'azure.storage'
Stack:   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 242, in _handle__function_load_request
    func_request.metadata.entry_point)
  File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/loader.py", line 66, in load_function
    mod = importlib.import_module(fullmodname)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/site/wwwroot/MyFunctionName/__init__.py", line 1, in <module>
    from azure.storage.blob import BlobSasPermissions, generate_blob_sas

Contents of the requirements.txt file:

--find-links wheelhouse
azure-storage-blob==12.3.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
Hazhzengcommented, May 20, 2020

Hi @JackStromberg,

To mitigate this issue, could you use func pack to resolve the dependencies on your local machine? This will generate a .zip file which contains .python_packages in it. Upload this zip file into storage account and use its SAS URL in WEBSITE_RUN_FROM_PACKAGE app setting should work.

2reactions
vrdmrcommented, May 16, 2020

@JackStromberg Could you confirm the following:

  • When you do func start, what version of python does it call out?
  • When you type python –version, what does it show?

The issue could be the modules version mismatch due to an update, which could be resolved by recreating python virtual environments.

rm -Recurse -Force .\.venv
python-3.8 -m venv .venv

Else, @Hazhzeng wrote a comprehensive list of diagnoses and mitigations in - Module not found issues Wiki, please let me know if that helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Function Python Module compatibility issue
functions as func would get detected but from azure.storage.blob import BlobClient remain unrecognized and will show the error as Import "azure.
Read more >
Troubleshoot Python errors in Azure Functions - Microsoft Learn
This error occurs when a Python function app fails to load a Python ... The package is incompatible with the Python interpreter version ......
Read more >
azure-storage-blob - PyPI
The Azure Storage Blobs client library for Python allows you to interact with three types of resources: the storage account itself, blob storage...
Read more >
Using importlib.metadata — Python 3.11.1 documentation
New in version 3.8. Changed in version 3.10: importlib.metadata is no longer provisional. ... importlib_metadata is a library that provides access to the...
Read more >
Databricks Runtime 8.3 for ML (Unsupported)
In this section: Top-tier libraries. Python libraries. R libraries. Java and Scala libraries (Scala 2.12 cluster) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found