Deploying a python function to a linux-consumption function app

Julius Gummersbach 0 Reputation points
2023-03-10T13:45:19.82+00:00

Context

You can find all of my code here

I am trying to deploy python code to an azure function via a zip package using the WEBSITE_RUN_FROM_PACKAGE app-setting as described here. My understanding is, that this is the only way to deploy function code to a linux function app using the consumption plan, as statet here.

I am uploading the zip file containing my function code to a storage blob in a container in the same storage account that the function app uses.
I then create a URL to the storage blob using an SAS token. I provide this URL to the function app in the WEBSITE_RUN_FROM_PACKAGE app-setting.
This is the recommended way as described here.
The URL I am providing is valid, when I enter it into a browser (even on another computer), the zip file is downloaded. The zip file contains the function_app.py , host.json and requirements.txt files from the functionApp directory.

Issue

The functions are not being executed and do not show up in the Azure Portal.
The only hint I have is this line in the log stream: FunctionsHostingConfigurations file does not exist
I found this issue on StackOverflow that might be related but it has not been answered yet.
You can find more logs of my function app in the logs directory.

The functions do run locally without issues. You can confirm this by yourself running the steps below.

Reproduce the issue

I am using terraform to automate my deployment, which makes it easy for You to reproduce my issue.
Using terraform, you should be able to exactly match my setup following these steps:

First, clone this GitHub repo.

Then enter a unique project name in terraform/terraform.tfvars After that, execute

cd terraform
terraform init
terraform apply

Run the function locally

If you want to confirm that the function runs locally, proceed like this: Run terraform output -json in the terraform directory. Enter the values you get from the last command into the corresponding fields in /functionApp/local.settings.json.
Then run:

cd ../functionApp
python -m venv .venv
.venv\scripts\activate
pip install -r requirements.txt

start the azurite storage emulator in a seperate process. You can install azurite with npm install -g azurite. Run azurite with azurite.
You can now run the functions. In /functionApp run:

func start

You can now observe in the azure portal, that new integers are added to the cosmosdb account every 5 seconds.

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

1 answer

Sort by: Most helpful
  1. Julius Gummersbach 0 Reputation points
    2023-03-23T13:56:17.19+00:00

    I was able to track down the issue to a specific import in the source code.

    I have posted a question concerning this here

    0 comments No comments