@Syed Muhammad Hani Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I understand that you are facing an error while deploying an Azure Function in Python to a Function App. The error message is Encountered an error (ServiceUnavailable) from host runtime.
You have already checked the connection strings and removed WEBSITE_RUN_FROM_PACKAGE from settings, but the issue persists.
Please follow the below action plan for now:
- Firstly, ensure that you have followed these pre-requisites in your local dev environment.
2.Also ensure that the Func Core tools are up to date.
3.Please check the AzureWebJobsStorage
setting in local.settings.json.
You need to update the value to the Azure Storage connection string:
DefaultEndpointsProtocol=https;AccountName=<ACCOUNT NAME>;AccountKey=<ACCOUNT KEY>;EndpointSuffix=core.windows.net
4.Please check if your Storage Account has the Firewall / Vnet / tunnelling enabled ? Could you please change the settings to All Network and check if that helps ? More info **here.
**
5.If your FunctionApp has Vnet enabled, check the suggestions here.
6.The language of your function app is maintained in the FUNCTIONS_WORKER_RUNTIME AppSetting in Azure Function App Portal. Please set python
as the value.
https://zcusa.951200.xyz/en-us/azure/azure-functions/functions-app-settings#functions_worker_runtime
7.Please try to deploy using the zip deployment method and check if that helps. You can use the below command to publish your function app:
func azure functionapp publish <APP_NAME>
8.Please check the Function App detectors by navigating to the Diagnose and Solve Problems section in the Azure Portal for the Functions as shown below: You can rely on the Function App Down or Reporting Errors setting:
9.Check the Azure Function App's logs to get more information about the error. You can do this by navigating to the Azure portal, selecting the Function App, and then selecting "Logs" from the left-hand menu. Look for any error messages or exceptions that could be causing the issue.
More Info here.
Hope this helps.
If none of the above action plan helps, please let me know. I would be happy to assist you further.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.