Deploy python azure function app from Gitlab from subfolder causes "Unable to find project root"

Andrii Mazur 1 Reputation point
2022-07-13T06:46:36.997+00:00

Hello Microsoft community. I am facing currently an issue with a deployment of Azure Function from GitLab CI/CD pipeline.

Given:
Following project structure:

-project
----src

----------
python_module

--------------------
some python code

----------
dummy-azure-func

--------------------
TimerTrigger1

--------------------
host.json

--------------------
...
----tests
----README.md
----...

GitLab CI/CD pipeline

default:
image: python:3.9

azure-function-deploy:
stage: deploy
script:
- apt-get update; apt-get install curl
- curl -sL https://aka.ms/InstallAzureCLIDeb | bash
- apt-get install curl && curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt-get install nodejs
- npm install -g azure-functions-core-tools@4 --unsafe-perm true
- az login --service-principal -u $AZ_DEPLOY_CLIENT_ID -p $AZ_DEPLOY_SECRET --tenant $AZ_DEPLOY_TENANT_ID
- func azure functionapp publish at-dummy-azure-func --python --prefix src/dummy-azure-func/

Expected: Successful deployment

Reality: Last "publish" command leads to the error "Unable to find project root. Expecting to find one of host.json in project root."

Executing the last command "func azure ..." on Win10 locally from "project" folder, deploys the Azure Function successfully. What shows that --prefix argument is working correctly, which is also running on GitLab

Had someone already experiences with deployment with "special" project structure?

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

1 answer

Sort by: Most helpful
  1. VinodNallavade 326 Reputation points
    2022-07-13T09:10:28.54+00:00

    Hi @Andrii Mazur , Welcome to the Microsoft Q&A Platform, and thanks for your query.

    Looking at the error message, you seems to be given a wrong path in your script section. The publish command is looking for host.json file.

    Can you please try below

    - func azure functionapp publish at-dummy-azure-func --python --prefix src/  
    

    Instead of

    - func azure functionapp publish at-dummy-azure-func --python --prefix src/dummy-azure-func/  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.

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.