Deploying Python Function Application with DevOps is moving files but not actually deploying application.

Rios, Karla 10 Reputation points
2023-12-15T01:13:37.9033333+00:00

 

I created a Python Azure Function (Model V2) using VS Code and following the Microsoft article linked below.  I used the default code for the Function Application.

https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python?pivots=python-mode-decorators

I used DevOps to set up a Build Pipeline and a Release Pipeline.  I could not find a Microsoft article that helped with deploying python Function Application. I used the article linked below (which is a few years old). The Tasks in the Release pipeline are not the same as the article, but everything else seemed to flow well. 

https://medium.com/globant/how-to-create-and-deploy-a-python-azure-function-using-azure-devops-ci-cd-2aa8f8675716

From the currently available tasks, the “Azure Function Deploy”-task  seemed the best and only fit. The screenshot below shows the Tasks available.

User's image

When I run the Release Pipeline, it runs successfully. I can see that all of the files were moved to the Function Application service, as seen in the screenshot below.  I also ran it multiple times with edits to comments in the default “function_app.py” file and added a new file to ensure the build pipeline + deployment pipeline were moving the documents.

User's image

However, there is no actual Function.  (See screenshot below).  Any idea on what modification is needed in the Deployment pipeline to make this work?

User's image

 

 

 

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,703 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rios, Karla 10 Reputation points
    2025-04-24T14:35:08.1166667+00:00

    @Alexander Kastil

    What ultimately fixed my issue was making some changes in the default build and release variables. Because my code was inside a hierarchy within the repo and the default script makes assumption on code being located in the root directory of the repo - it caused the artifacts to deploy incorrectly. Note that the build script is sensitive to capitalization - so the names of the folders have to match exactly in the build script. Below are some pointers I noted for my team based on my experience last year. I am not sure if they are applicable to you or the current version of DevOps you may be using.

    For reference below is what my repo looked like. Note that I created my repo first, then cloned it locally before building the function application. This is why this hierarchy was created:

    User's image

    Azure Function Dev Ops Build Pipeline & Repo

    • Artifact building and repo considerations: When the Repo is initially created in VS CODE, the function will be created as a directory within the repo. The Build Pipeline will require modifications to build from the function application folder, and not the repo. The folder for the function application that is being deployed needs to be explicitly named in the tasks of the build pipeline. Here are the places where the name must be updated. The name must match exactly in capitalization and spacing.
    • Build extensions script should look as the following but replace with your Function Name:

    #Function name and Function Application Directory is "ProjectParamSearch" if [ -f extensions.csproj ] then dotnet build extensions.csproj --output ./bin fi pip install --target="./ProjectParamSearch/.python_packages/lib/site-packages" -r ./ProjectParamSearch/requirements.txt

    • Archive Files, root folder needs to be changed from the Default: $(System.DefaultWorkingDirectory) to the following: $(System.DefaultWorkingDirectory)/ProjectParamSearch

    NOTE that "ProjectParamSearch" would be replaced with your specific Function Application Directory Name

    • Agent job must be "ubuntu latest"
    • Python Versions in artifact build:

    Using any of the templates (YAML or Classic) to create a pipeline will default to python versions 3.6.  However, if you are using VS Code to build your Function Application, it will default to the latest version python version.  Any reference to the version will have to be manually updated to match up with your local code.  If it's not changed, the library files installed during the build may not be the latest ones.

    Release pipeline considerations

    • Run Agent Tasks, Package configuration will require to be changed to match your directory within the repo. Example you may have the default:

    $(System.DefaultWorkingDirectory)/**/*.zip

    • To match your repo/directory, for example: $(System.DefaultWorkingDirectory)/_ProjectParamSearch/drop/*.zip

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.