I am trying to use an Azure Function to generate a SAS token. The import statement is failing.
import azure.functions as func
from azure.storage.blob import generate_container_sas
with
Exception: ModuleNotFoundError: No module named 'azure.storage'.
Troubleshooting Guide: https://aka.ms/functions-modulenotfound
Stack: File "C:\Program Files\Microsoft\Azure Functions Core
Tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\
dispatcher.py", line 266, in _handle__function_load_request
func = loader.load_function(
File "C:\Program Files\Microsoft\Azure Functions Core
Tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\utils\
wrappers.py", line 34, in call
raise extend_exception_message(e, message)
File "C:\Program Files\Microsoft\Azure Functions Core
Tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\utils\
wrappers.py", line 32, in call
return func(*args, **kwargs)
File "C:\Program Files\Microsoft\Azure Functions Core
Tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\
loader.py", line 76, in load_function
mod = importlib.import_module(fullmodname)
File "C:\Users\2259252\AppData\Local\Programs\Python\Python38\lib\
importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Projects\Additive\SkyforgeAPI\FileAPI\RequestFileUpload\
__init__.py", line 4, in <module>
from azure.storage.blob import generate_container_sas.
Package is installed in the venv
$ .venv/Scripts/python -m pip freeze
azure-core==1.9.0
azure-functions==1.5.0
azure-storage-blob==12.6.0
...
My requirements.txt file:
azure-functions
azure-storage-blob==12.6.0
What am I missing?
Closest question
From you description, it seems you are based on global environment instead of running in .venv
environment.
Please pay attention to this:
If you are based on Windows OS, then I think you need to use below command:
cd .venv
then
.\Scripts\activate.bat
After all, run
cd ..
func host start
After that, It works fine on my side.