Azure Functions Deployment

ash 66 Reputation points
2022-10-17T10:14:30.587+00:00

I successfully created an Azrue function using Python and was able to deploy it via VS code.

I tried to deploy via Azure Devops where the build and the release pipeline completed successfully. But my function URL is not working. When I checked the Application Insight metric, I was able to see that the python script is failing in the very first line.

import shap

The requirements.txt file has the shap library as part of the list of libraries to be installed. In the build pipeline I am able to see that the library was downloaded successfully without any warning. When I downloaded the zip file used for deployment, I see that the requirements.txt file is present as part of the zip file, but no wheel file was present. The zip file looks like a copy of my git repository.

I am wondering whether I should give any command to install the libraries in the deploy pipeline.

  • Questions
  • What's the purpose of downloading the wheel files during the build process?
  • When the library wheel files were downloaded during the build process, why it's not present in the zip file generated?
  • When the zip file contains only the Azure-git repo contents, why can't we connect the Azure git repo instead?

I am using the Azure function template from Devops library for the Build and release pipeline and my function was built on top of Consumption plan. The YaML contents of my pipeline is present below

------------------------------------------------

pool:

name: Azure Pipelines

steps:

  • bash: |
    if [ -f extensions.csproj ]
    then
    dotnet build extensions.csproj --output ./bin
    fi displayName: 'Build extensions'
  • task: UsePythonVersion@0 displayName: 'Use Python 3.8' inputs: versionSpec: 3.8
  • bash: |
    python3.8 -m venv worker_venv
    source worker_venv/bin/activate
    pip3.8 install setuptools
    pip3.8 install -r requirements.txt displayName: 'Install Application Dependencies'
  • task: ArchiveFiles@2 displayName: 'Archive files' inputs: rootFolderOrFile: '$(System.DefaultWorkingDirectory)' includeRootFolder: false
  • task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: drop'
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ash 66 Reputation points
    2022-10-25T09:50:53.67+00:00

    I fixed it myself. Firstly the virtual environment creation step had a mistake. 'bin' was referring to Linux agent but I was running on a windows agent.
    After fixing it, the zip file had the downloaded packages from the build step.

    Additionally I also followed this link which helped to complete the build.

    Followed by that the deployment step completed successfully and now the function is working fine.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.