skip to Main Content

The deployment with vscode run 100% fine,
in the log I see it uses oryx.

header:

import datetime
import logging
import adal
import requests
import json

I want to upload the code using Azure Pipelines though, for the sake of automation.
Here is my code

    steps:
      - bash: |
          if [ -f extensions.csproj ]
          then
              dotnet build extensions.csproj --output ./bin
          fi
        displayName: 'Build extensions'
      - task: UsePythonVersion@0  
        displayName: 'Use Python 3.9'  
        inputs:  
          versionSpec: '3.9'
      - bash: |
          python3.9 -m venv worker_venv
          source worker_venv/bin/activate
          pip3.9 install setuptools
          pip3.9 install -r requirements.txt
        displayName: 'Install application dependencies'
      - task: ArchiveFiles@2
        displayName: "Archive files"
        inputs:
          rootFolderOrFile: "$(System.DefaultWorkingDirectory)/functions"
          includeRootFolder: false
          archiveType: zip
          archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
          replaceExistingArchive: true
      - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        artifact: drop
      - task: AzureFunctionApp@1
        displayName: 'Deploy functions to Function App'
        inputs:
          azureSubscription: Service-Conn
          appType: functionAppLinux
          appName: 'pythontest'
          package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
          runtimeStack: 'Python|3.9'
          deploymentMethod: 'zipDeploy'
          resourceGroupName: $(resourcegroup_name_app)

But I end up with module not found error (in the monitor of function in azure portal).

Result: Failure Exception: ModuleNotFoundError: No module named 'adal'.

the uploaded zip have site packages
there is no error in pipeline

What am I missing? Any ideas guys?

2

Answers


  1. I believe you have to run a task to install pip in pipeline console. See link below for better clarity: https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops

    Login or Signup to reply.
  2. pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt is the command you want to run if you need to ship your libraries in the deployment zip file instead of running pip on function app service.

    Your pipeline code installed libraries into .venv and function app runtime will not use that folder.

    refs:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search