Azure Function PermissionError: [Errno 13] Permission denied wwwroot

James, Mark 55 Reputation points

Hi, I'm trying to create an Azure Function to run dbt (data build tool), although can't get the Function to work when deployed - works fine locally.

The below generates a dbt command to be executed in the dbt project and outputs the response to the log:

    with Popen([“/home/site/wwwroot/dbtcore/dbt_project”, "dbt", "run", "--select", var_model], stdout=PIPE) as proc:
        for line in proc.stdout:
            line = line.decode('utf-8').replace('\n', '').strip()
            line = self.ansi_escape.sub('', line)        

The App Service Plan OS is Linux and EP2 Function App Premium.
Function as code and uploaded as .zip

The error I'm getting is:

Result: Failure Exception: PermissionError: [Errno 13] Permission denied: '/home/site/wwwroot/dbtcore/dbt_project' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/", line 458, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/"

I don't beleive its a file write issue as get a different error when trying to write a dummy .txt file to wwwroot.

Any pointers on solving this issue would be much appreciated

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

2 answers

Sort by: Most helpful
  1. James, Mark 55 Reputation points

    After a lengthy investigation my issue was that I could not access the dbt package in the default pip install location that Azure Function Publish as Code places packages in the requierments.txt file.

    I created a new Function publishing as Docker as opposed to Code.

    In addition I set-up a Azure DevOps Pipeline and atler the default pip install path which is:

    pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt

    And set the path to: pip install -r ./requirements.txt in the azure-pipelines.yml file.

    I'm unsure if the default pip install location can be altered when publishing as Code.

    More info can be found in this stackoverflow post

  2. MughundhanRaveendran-MSFT 11,621 Reputation points Microsoft Employee

    If you have the WEBSITE_RUN_FROM_PACKAGE app setting enabled and value set to 1 or url, then the wwwroot folder becomes read only and your script wont be able to write the data. So please remove the app setting or set it to 0 and then do a remote build to deploy the function to Azure function runtime. This should enable you to write the data in the wwwroot folder.

    Hope this helps! Feel free to reach out to me if you have any queries or concerns.