Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JackStromberg opened this issue May 15, 2020 · 7 comments
Closed
Assignees
Labels

Comments

@JackStromberg
Copy link
Member

JackStromberg commented May 15, 2020

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.
Azure/azure-sdk-for-python#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

@vrdmr vrdmr self-assigned this May 16, 2020
@vrdmr
Copy link
Member

vrdmr commented 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.

@JackStromberg
Copy link
Member Author

Running the script in the context of the Function app, I show version 3.8.2. I'm doing all testing in the context of the Azure Function in Azure, not on my local machine.

@Hazhzeng
Copy link
Contributor

Hi @JackStromberg,

Which tool did you use to publish into Azure, are you using functions core tools (func azure functionapp publish <appname>)? Or VSCode?

Because it seems like you're trying to deploy a Python 3.8 project onto a Python 3.6 Azure Function App.
Stack: File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 242, in _handle__function_load_request

@Hazhzeng
Copy link
Contributor

As discuss offline, the customer is using an ARM template and ZipDeploy extension. The ZipDeploy endpoint fails with 400. I believe this is a bug on KuduLite. (mentioned in: Azure-App-Service/KuduLite#117 Azure-App-Service/KuduLite#118)

                {
                    "name": "[concat(parameters('name'), '/ZipDeploy')]",
                    "type": "Microsoft.Web/sites/extensions",
                    "apiVersion": "2015-08-01",
                    "dependsOn": [
                        "[concat('Microsoft.Web/sites/', parameters('name'))]"
                    ],
                    "properties": {
                        "packageUri": "https://asdfzxcfdslinux.blob.core.windows.net/samples-workitems/Python38OryxBuild.zip?st=2020-05-20T22:46:56Z&se=2022-05-21T22:46:00Z&sp=rl&sv=2018-03-28&sr=b&sig=p+SA0jEIhxxfcDj9lXy17QEGN4mc5QscHcvElIDWA7M="
                    }
                }

@Hazhzeng
Copy link
Contributor

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.

@JackStromberg
Copy link
Member Author

Generating the zip containing the .python_packages worked perfect! Thank you so much!

@laurent-33
Copy link

Hi,

Thank you a lot, three days I have been stuck trying both possible options without success : ARM zipdeploy extension (not found error), and run from package (I tried to rename .venv to .python_package but it did not work)

=> func pack is good workaround !

notes :

  • in my case basic "$func pack" command have not worked ("binary dependencies without wheels are not supported"), tried activating venv but still the error
  • tried "$func pack --build remote" as indicated in the error message, but same error

-> I had to use "$func pack --build-native-deps" to get it worked
(but it requires docker desktop, hopefully I have it already installed, and pull the 1Gb image so a bit network bandwidth waste!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants