azure-functions-host: Running Azure Functions works locally but fails upon deployment with "1 functions found (Custom) 0 functions loaded"

I have an Azure Function that works locally. But when I deploy it to the cloud, it apparently doesn’t load and therefore doesn’t execute. The logs from the deployed code show: 1 functions found (Custom) 0 functions loaded message. Here’s what’s happening in more detail:

My application is running on Python 3.9. When I run it locally using the Run and Debug mode in VS Code, I can see it executes successfully in the terminal output.

Then I try deploying from VS Code to my Function App:

image

And the terminal output shows the deployment is successful:

Deployment successful. deployer = ms-azuretools-vscode deploymentPath = Functions App ZipDeploy. Extract zip. Remote build.

But when I go to the Function App in the Azure Portal, no functions are listed there:

image

And the log stream shows:

Connected!
2023-12-01T21:08:00Z   [Verbose]   Initiating background SyncTriggers operation
2023-12-01T21:08:00Z   [Information]   Loading functions metadata
2023-12-01T21:08:00Z   [Information]   Reading functions metadata (Custom)
2023-12-01T21:08:00Z   [Information]   1 functions found (Custom)
2023-12-01T21:08:00Z   [Information]   0 functions loaded
2023-12-01T21:08:00Z   [Information]   Loading functions metadata
2023-12-01T21:08:00Z   [Information]   Reading functions metadata (Custom)
2023-12-01T21:08:00Z   [Information]   1 functions found (Custom)
2023-12-01T21:08:00Z   [Information]   0 functions loaded
2023-12-01T21:10:31Z   [Verbose]   Received request to drain the host
2023-12-01T21:10:31Z   [Information]   DrainMode mode enabled
2023-12-01T21:10:31Z   [Information]   Calling StopAsync on the registered listeners
2023-12-01T21:10:31Z   [Information]   Call to StopAsync complete, registered listeners are now stopped

So it seems like the code is deploying but the Function App can’t load it for some reason.

Have looked around for a solution but no luck yet. I found this thread but it looks like that was specifically related to functions failing locally, whereas my function runs locally but not when deployed to the cloud. Hoping this thread can help me figure out my particular issue.

  • Language and version: Python 3.9
  • Function App runtime version: 4.27.5.5
  • Region: East US

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 51 (1 by maintainers)

Most upvoted comments

Would also love to know the proper way to understand why the Azure Function can’t load the found functions.

Also worth mentioning that there was some kind of breaking change (probably in Microsoft.Azure.Functions.Worker.Sdk package) that lead to .azurefunctions folder not being added to the publish output using this command:

dotnet publish Functions -c Release -o ${{env.DOTNET_ROOT}}/functions

Before everything was working using the same command in our CI pipeline.

UPDATED:

It turns out that folks decided to make a breaking change in MINOR version of GitHub upload artifact action that stopped including hidden files and folders: https://github.com/actions/upload-artifact/releases/tag/v3.2.0

Now you have to pass include-hidden-files flag to include .azurefunctions folder in an artifact:

      - name: Upload Functions Artifact
        if: ${{ inputs.upload-artifacts }}
        uses: actions/upload-artifact@v4
        with:
          name: functions-artifact
          path: ${{env.DOTNET_ROOT}}/functions
          include-hidden-files: true

Hope it will be helpful for someone.

What should be the proper way to understand why the Azure Function can’t load the found functions?!

For anyone running into a similar issue but with dotnet: additionally to fixing the file structure of the zip, make sure your pipeline copies all the files from the build. This includes the hidden .azurefunctions folder that is created.

Hey @jonmunm I made a small breakthrough yesterday. Not a very satisfying conclusion but it looks like switching from psycopg2 to psycopg unbroke things. More details below in case they’re useful:

My Python script connects to a Postgres DB so I was using psycopg2 to make that connection. Then we were doing some testing and I tried switching from psycopg2 to psycopg (my requirements.txt file includes both psycopg and psycopg-binary). It worked locally so I deployed to my function app and now it works.

I still don’t fully understand why this change resulted in a successful build. For one thing, both psycopg2 and psycopg are supposed to work with Python 3.7 and above (I’m running Python 3.9).

But the bigger problem I have with this process is that there was basically no visibility into the build failure within the function app. The logs simply showed “1 functions found (Custom) 0 functions loaded”. We had no idea why they weren’t loading and why the function would run locally but not in the cloud.

Same issue with dotnet-isolated|8.0. 1 functions found , 0 functions loaded.

Also worth mentioning that there was some kind of breaking change (probably in Microsoft.Azure.Functions.Worker.Sdk package) that lead to .azurefunctions folder not being added to the publish output using this command:

dotnet publish Functions -c Release -o ${{env.DOTNET_ROOT}}/functions

Before everything was working using the same command in our CI pipeline.

UPDATED:

It turns out that folks decided to make a breaking change in MINOR version of GitHub upload artifact action that stopped including hidden files and folders: https://github.com/actions/upload-artifact/releases/tag/v3.2.0

Now you have to pass include-hidden-files flag to include .azurefunctions folder in an artifact:

      - name: Upload Functions Artifact
        if: ${{ inputs.upload-artifacts }}
        uses: actions/upload-artifact@v4
        with:
          name: functions-artifact
          path: ${{env.DOTNET_ROOT}}/functions
          include-hidden-files: true

Hope it will be helpful for someone.

That’s such a strange inclusion on a minor change. Thank you so much mate, lifesaver!

Working with Functions CLI to deploy is the only way it is working right now. This thread should be reopened and deliver a ticket or whatever the procedure is to pay it attention to have a solution on DevOps and the remaining deployment methods.

Regards

Hi all,

I was running into the same issues mentioned above. I was using the Deployment Center in the Azure Function App to connect it to my GitHub, and no matter which packages I installed inside my requirements.txt file—even something as common as requests—the function trigger would not show up in the portal when deployed because it couldn’t find the packages.

The solution I found was to zip up the library packages during the GitHub build instead of letting Oryx do the remote build. Here are the changes I made to the GitHub workflow file to achieve this:

  1. Inside the “Install dependencies” step of the build job, change the pip install command pip install --target=".python_packages/lib/site-packages" -r requirements.txt
  2. Inside the “Zip artifact for deployment” step of the build job, change the zip command so it includes the python_packages zip release.zip .python_packages ./* -r
  3. Inside the “Deploy to Azure Functions” step of the deploy job, change these values so it doesn’t do a remote build scm-do-build-during-deployment: false enable-oryx-build: false

This way you can still use the V2 programming model and can use Github Actions instead of VSCode to deploy to the Azure Function.

This is still happening! Reopen and tell us what is going on

worked for me, cleanup of the artifact and setting it up from scratch helped

to be more exact in my case, instead of building function app artifact locally, i pushed the responsibility to azure:

func azure functionapp publish FUNC_APP_NAME --subscription SUB_ID --publish-local-settings

/bot not-stale

For whose of you dealing with this issue with Node.js runtime.

For me the issue was that node failed to initially load the function while trying to resolve imports

I’ve found the issue in Diagnostic Dump zip you can get from Kudu https://{app-name}.scm.azurewebsites.net/api/dump .

Look in the files in LogFiles\Application\Functions\Host directory. For me it looked like this:

{timestamp} [Debug] Hosting starting
{timestamp} [Error] Error: Worker was unable to load entry point "dist/functions/{function-name}.js": Cannot find module ''
{timestamp} [Information] Require stack:
{+ bunch of lines with error stacktrace under [Information]}

Also note that I’ve changed logging config in host.json to firehose everything:

"logging": {
	"console": {
		"isEnabled": true,
		"DisableColors": false
	},
	"applicationInsights": {
		"samplingSettings": {
			"isEnabled": false
		}
	},
	"fileLoggingMode": "always",
	"logLevel": {
		"default": "Trace",
		"Host": "Trace"
	}
},

It’s likely that you can find the same info in log stream or app insights but that did not worked for me for some reason.

For anyone looking for a fix, for me this this occurs when there is code before the function handlers (at least in python) that errors. This code runs on function init, and therefore if there is errors in this code Azure will fail to find the functions.

I am using .net 8 after switching to use windows hosting for azure function and changing the Microsoft.Azure.Functions.Worker.Sdk version to 1.15.1 and deploying via vs code, the function appeared in the function app. Deploying via azure function cli or via github actions, did not help.

I was thinking if the downgrade does not work, I will try using .net 6. but did not have to.

I have the same issue using .NET 8 dotnet-isolated and Azure DevOps. It was migrated from dotnet 6.0 which was working fine.

Yes @seeess1 , of course. Somehow, deploying via VS Code make the function visible and loadable in Azure. That’s why I posted both logs, from VS Code Deploy and Github actions, assuming that the last one is not doing “something” so that the function is loaded and visible …

I’m also have no idea why this happend. I think that is a third-party integration. That is, a VS Code deploy is “better” prepared to get things ready in Azure, and Github is not.

That’s way I’m running a test preparing DevOps Pipeline, which has fully integration with Azure.

I am seeing the same issue, however my function in written in C# .NET 8 isolated worker. The message A function allow list has been specified, excluding all but the following functions: [function name] is is in the trace log, but the function is found, but not loaded

will check and update.Thanks for reporting.