Azure function for python is unreachable

Viewed 792

I am getting the below error in the Azure Function for Python

Please see the below screenshot

enter image description here

Whenever I am trying to open the azure function python on the portal then I got the above error. Let me know if anyone has any idea regarding this error.

1 Answers

This error can be very difficult to debug, because it seems to be caused by multiple root causes. In my case, I suspect the root cause to be a failure in pip package installation. But this is difficult to verify, because I was not able to drill in to the pip logs. The deployment log does not contain information about pip installation, and some of the logs were unavailable because the host runtime was down.

I followed these best practices to finally make the Python function deployment succeed:

  • Use remote build (app setting: SCM_DO_BUILD_DURING_DEPLOYMENT: 1)
  • Make sure that the AzureWebJobsStorage application setting is configured to point to the correct Function Storage
  • Do not include local .venv/ directory in deployment (add it to .funcignore)
  • Make sure the dependencies can be installed on the local Virtual Environment without conflicts
  • Test that the function runs locally without errors

In requirements.txt, I had the following lines. Note that there is no need to specify azure-functions version, since it is determined by the platform. It is only for local linting etc.

pip==21.2.*
azure-functions

As a side note, it is not necessary to specify "Build from package" (app setting: WEBSITE_RUN_FROM_PACKAGE: 1); this seems to be enabled by default.

My deployment configuration:

  • OS: Ubuntu 21.04
  • Functions Python version: 3.9
  • Functions Runtime Extension version: 4
  • Deployed with VS Code Azure extension
Related