English 中文(简体)
Function App deployment succeeds but fails to import packages (python, linux, consumption plan)
原标题:

Local deployment directly of a function app using vscode succeeds and the function app works, however when trying to build and deploy through Azure Devops, the deployment succeeds but there is an error when importing numpy.

Result: Failure Exception: ImportError: Unable to import required dependencies: numpy: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.10 from "/usr/local/bin/python" * The NumPy version is: "1.25.0" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No module named  numpy.core._multiarray_umath  . Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound

azure-pipelines.yml is very similar to examples, install dependencies and zip:

variables:
  # Azure Resource Manager connection created during pipeline creation
  azureSubscription:  azureSubscription 

  # Agent VM image name
  vmImageName:  ubuntu-20.04 

  # Working Directory
  workingDirectory:  $(System.DefaultWorkingDirectory)/ 
stages:
- stage: Build
  displayName: Build stage

  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - bash: |
        if [ -f extensions.csproj ]
        then
            dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
        fi
      workingDirectory: $(workingDirectory)
      displayName:  Build extensions 

    - task: UsePythonVersion@0
      inputs:
        versionSpec:  3.x  # string. Required. Version spec. Default: 3.x.
        architecture:  x64  #  x86  |  x64 . Required. Architecture. Default: x64.

    - bash: |
        pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
      workingDirectory: $(workingDirectory)
      displayName:  Install application dependencies 

    - task: ArchiveFiles@2
      displayName:  Archive files 
      inputs:
        rootFolderOrFile:  $(workingDirectory) 
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

    - task: AzureFunctionApp@2
      inputs:
        azureSubscription:  azureSubscription 
        appType:  functionAppLinux 
        appName:  app-name 
        package:  $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip 
        deploymentMethod:  auto 

The code is then deployed to the function:

steps:
- task: AzureFunctionApp@2
  displayName:  Azure Function App Deploy 
  inputs:
    azureSubscription:  azureSubscription 
    appType: functionAppLinux
    appName:  app-name 
    package:  $(System.DefaultWorkingDirectory)/_Function App/drop/*zip 
    deploymentMethod: zipDeploy

Any help much appreciated, have spent hours looking at examples and reading through the documentation but still haven t got this working. Cheers.

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签