Skip to content

Exception: ModuleNotFoundError: No module named '_cffi_backend' #20427

Closed

Description

  • Package Name: azure-blob-storage
  • Package Version: 12.8.1
  • Operating System: Azure Function App
  • Python Version: 3.6

Describe the bug

When running the function app, this error is thrown:

Result: Failure
Exception: ModuleNotFoundError: No module named '_cffi_backend'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound
Stack:   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 309, in _handle__function_load_request
    func_request.metadata.entry_point)
  File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call
    raise extend_exception_message(e, message)
  File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call
    return func(*args, **kwargs)
  File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/loader.py", line 83, 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/Calculate/__init__.py", line 5, in <module>
    from azure.storage.blob import BlobServiceClient
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/__init__.py", line 10, in <module>
    from ._blob_client import BlobClient
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/_blob_client.py", line 27, in <module>
    from ._shared.encryption import generate_blob_encryption_data
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/_shared/encryption.py", line 19, in <module>
    from cryptography.hazmat.primitives.padding import PKCS7
  File "/home/site/wwwroot/.python_packages/lib/site-packages/cryptography/hazmat/primitives/padding.py", line 11, in <module>
    from cryptography.hazmat.bindings._padding import lib

To Reproduce
I have set this in requirements.txt:

azure-functions
azure-storage-blob

I am deploying the function via github Actions like this:

name: Deploy Function

on: [push]

env:
  AZURE_FUNCTIONAPP_NAME: xxx
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'
  PYTHON_VERSION: '3.6'

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@v2

    - name: Setup Python ${{ env.PYTHON_VERSION }} Environment
      uses: actions/setup-python@v1
      with:
        python-version: ${{ env.PYTHON_VERSION }}

    - name: 'Resolve Project Dependencies Using Pip'
      shell: bash
      run: |
        pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
        python -m pip install --upgrade pip
        pip install -r requirements.txt --target=".python_packages/lib/site-packages"
        popd

    - name: 'Run Azure Functions Action'
      uses: Azure/functions-action@v1
      id: fa
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
        package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
        publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}

Strangely, if I deploy the function from my mac using func azure functionapp publish xxx it does work, even though it seems to be deploying in Python 3.6 as well:

Downloading and extracting 'nodejs' version '14.17.4' to '/tmp/oryx/platforms/nodejs/14.17.4'...
Downloaded in 1 sec(s).
Verifying checksum...
Extracting contents...
Done in 3 sec(s).

Downloading and extracting 'python' version '3.6.12' to '/tmp/oryx/platforms/python/3.6.12'...
Downloaded in 0 sec(s).
Verifying checksum...
Extracting contents...
Done in 3 sec(s).

Expected behavior

It should not crash whether I deploy locally or from Github

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

Deployment logs on Github Actions:

Run Azure/functions-action@v1
  with:
    app-name: xxx
    package: .
    publish-profile: ***
    respect-pom-xml: false
    respect-funcignore: false
    scm-do-build-during-deployment: false
    enable-oryx-build: false
  env:
    AZURE_FUNCTIONAPP_NAME: xxx
    AZURE_FUNCTIONAPP_PACKAGE_PATH: .
    PYTHON_VERSION: 3.6
    pythonLocation: /opt/hostedtoolcache/Python/3.6.14/x64
Successfully parsed SCM credential from old publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
Successfully acquired app settings from function app (with SCM credential)!
Will archive . into /home/runner/work/_temp/temp_web_package_8622910865863398.zip as function app content
Will use Kudu https://<scmsite>/api/zipdeploy to deploy since publish-profile is detected.
Setting SCM_DO_BUILD_DURING_DEPLOYMENT in Kudu container to false
Update using Client.updateAppSettingViaKudu
Response with status code 204
App setting SCM_DO_BUILD_DURING_DEPLOYMENT propagated to Kudu container
Setting ENABLE_ORYX_BUILD in Kudu container to false
Update using Client.updateAppSettingViaKudu
Response with status code 204
App setting ENABLE_ORYX_BUILD propagated to Kudu container
Package deployment using ZIP Deploy initiated.
Deploy logs can be viewed at https://xxx
Successfully deployed web package to App Service.
Successfully updated deployment History at https://xxx
Response with status code 204
Response with status code 204
Response with status code 204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Service AttentionWorkflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions