Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Python Functions do not get detected by azure function app when deployed to azure

Open nimbusnext-malhar opened this issue 8 months ago • 5 comments

  • create new function in empty dir using func init
  • add a simple endpoint such as /hello to it
@app.route(route="hello", methods=["GET"], auth_level=func.AuthLevel.ANONYMOUS)
def hello(req: func.HttpRequest) -> func.HttpResponse:
	name = req.params.get("name")
	if not name:
		return func.HttpResponse(
			json.dumps({"error": "Name parameter is required"}),
			status_code=400,
			mimetype="application/json"
		)

	response = {
		"message": f"Hello, {name}!",
		"timestamp": datetime.datetime.now(datetime.UTC).isoformat()
	}
	return func.HttpResponse(
		json.dumps(response),
		status_code=200,
		mimetype="application/json"
	)
 
  • run func azure functionapp publish $functionAppName // var set before in env/script
  • functions show up in the deployment logs as well as in the portal like this
[2025-05-15T11:06:13.714Z] The deployment was successful!
Functions in MyFunctionAppName:
    healthcheck - [httpTrigger]
        Invoke url: https://MyFunctionAppName.azurewebsites.net/api/hello

but, in another function app, this does not happen, the functions never show up

logs would be:


Getting site publishing info...
[2025-05-15T10:44:52.557Z] Starting the function app deployment...
[2025-05-15T10:44:52.568Z] Creating archive for current directory...
Performing remote build for functions project.
Deleting the old .python_packages directory
Uploading 81.74 KB [##############################################################################]
Deployment in progress, please wait...
Starting deployment pipeline.
[Kudu-SourcePackageUriDownloadStep] Skipping download. Zip package is present at /tmp/zipdeploy/<redacted>.zip
[Kudu-ValidationStep] starting.
[Kudu-ValidationStep] completed.
[Kudu-ExtractZipStep] starting.
[Kudu-ExtractZipStep] completed.
[Kudu-ContentValidationStep] starting.
[Kudu-ContentValidationStep] completed.
[Kudu-PreBuildValidationStep] starting.
[Kudu-PreBuildValidationStep] completed.
[Kudu-OryxBuildStep] starting.
[Kudu-OryxBuildStep] completed.
[Kudu-PostBuildValidationStep] starting.
[Kudu-PostBuildValidationStep] completed.
[Kudu-PackageZipStep] starting.
[Kudu-PackageZipStep] completed.
[Kudu-UploadPackageStep] starting.
[Kudu-UploadPackageStep] completed. Uploaded package to storage successfully.
[Kudu-RemoveWorkersStep] starting.
[Kudu-RemoveWorkersStep] completed.
[Kudu-SyncTriggerStep] starting.
[Kudu-CleanUpStep] starting.
[Kudu-CleanUpStep] completed.
Finished deployment pipeline.
Checking the app health.... done
[2025-05-15T10:47:35.888Z] The deployment was successful!
Functions in <AnotherAPP-actual name redacted>:

func start works and shows the functions to be present

how do we debug this ? if it is some requirements issue ? Or if it is misconfiguration ? or if this is some function runtime bug ?

nimbusnext-malhar avatar May 15 '25 11:05 nimbusnext-malhar

Hello @nimbusnext-malhar, Thanks for the detailed info.

Let me quickly address your questions:

1. How do we debug this?

First thing you can check is the Kudu console. Go to Debug console > CMD > site > wwwroot and see if your function folders and function.json files are there. If these are missing or inside any extra folder layer, the runtime will not pick . 2. Requirements issue?

Since your app is starting fine locally with func start. That usually means dependencies are okay.

3. Misconfiguration?

It might be possible. Make sure FUNCTIONS_WORKER_RUNTIME is set to python and FUNCTIONS_EXTENSION_VERSION is set properly. Also, cross check that functions should be under wwwroot in zip.

4. Runtime bug?

Don't seem like a bug. Since it is working on one function app and not the other. This kind of issue is usually due to structure or config differences during deployment.

raushan2998 avatar May 15 '25 14:05 raushan2998

@raushan2998

case 1: I have a bare function generated via func cli Yes, for apps hosted on web app plan, there is a debug menu and I can see files, bit no functions show up for app on consumption plan, I see the functions in portal, they do RUN, but I do not see a debug menu for it

case 2: function app which has some of my code, some dependencies, originally generated NO, it does not work anywhere,

on web app plan hosting, Yes I see the files on consumption plan hosting I do not see a debug menu, so not sure how to look up files

I had doubts on my code, so I created the bare function app as case 1 and as described originally, I also had doubts on deployment, so I created different functions on diff plans, to try different things

nimbusnext-malhar avatar May 16 '25 05:05 nimbusnext-malhar

Got it. Thanks for the detailed testing. Since the bare function works across both plans, the platform and deployment flow seem fine. For Case 2, if functions aren’t showing up despite files being present, especially on Web App Plan, it’s likely a structure issue. You can check if each function has its own folder with a valid function.json. Also, confirm FUNCTIONS_WORKER_RUNTIME=python. On Consumption Plan, there is lack of debug console, but App Insights or Log Stream might help confirm if the function is even loaded.

raushan2998 avatar May 19 '25 13:05 raushan2998

case 1: I have a bare function generated via func cli Yes, for apps hosted on web app plan, there is a debug menu and I can see files, bit no functions show up for app on consumption plan, I see the functions in portal, they do RUN, but I do not see a debug menu for it

@raushan2998 You seem to have mis-read

case 1 : for app on web app plan, with bare function app code, no functions show up

so, this is untru

Got it. Thanks for the detailed testing. Since the bare function works across both plans, the platform and deployment flow seem fine.

nimbusnext-malhar avatar May 20 '25 07:05 nimbusnext-malhar

I am facing this too. I see the code from az-cli, status = 6 from response deployment_status_url = scm_url + '/api/deployments/latest'

https://github.com/Azure/azure-cli/blob/dev/src/azure-cli/azure/cli/command_modules/appservice/custom.py#L6526

if status == 6:
            raise CLIError("Deployment was partially successful. These are the deployment logs:\n{}".format(
                           json.dumps(show_deployment_log(cmd, rg_name, name))))

this happens very intermittently and does not seem to change even if my source changes

aljorhythm avatar May 21 '25 08:05 aljorhythm