azure-functions-python-worker: [BUG] Azure function python v2 not visible in Azure Portal after deployment
Follow the steps mentioned in the document to deploy the function. https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python?pivots=python-mode-decorators
Investigative information
Please provide the following:
- Timestamp: always happening
- Core Tools version: V1.2.0, through VS code extension
- VS code- 1.83.1
Repro steps
Provide the steps required to reproduce the problem:
- Follow steps as in above doc
- Create a blob trigger function
- add the below requirements.txt
- add the below to app.py
- test locally- runs perfectly!
- deploy to azure using VS code, right click “deploy to azure”, once successful - DOESNT SHOW IN PORTAL.
–>
Expected behavior
Provide a description of the expected behavior.
- The function should be visible on portal
- The function should be executed once blob is uploaded into the blob-storage
- Expected to work as it behaves on local.
Actual behavior
Provide a description of the actual behavior observed.
- Cannot find the function
- The function doesnt execute when the endpoint is hit
- the local test works but the deployed function doesnt
- fails in consumption plan
- fails in app service plan
Known workarounds
Provide a description of any known workarounds.
No workarounds
Contents of the requirements.txt file:
Provide the requirements.txt file to help us find out module related issues.
Files at the end
Related information
Provide any related information
- No specific source files except the two above
- Python version used - 3.9.13
- referred these but not helpful to fix the bug https://learn.microsoft.com/en-us/azure/azure-functions/machine-learning-pytorch?tabs=bash
- https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#comment134830419_76463210
Source
import azure.functions as func
import logging
import os
#qdrant
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams,PointStruct
#encoder for vecotrizing embeddings
from sentence_transformers import SentenceTransformer
from langchain.document_loaders import PyPDFLoader
from langchain.document_loaders import DirectoryLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
#https://stackoverflow.com/questions/75627362/azure-functions-python-error-no-job-functions
app = func.FunctionApp()
@app.blob_trigger(arg_name="myblob", path="mycontainer",
connection="BlobStorageConnectionString")
def blob_trigger(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob"
f"Name: {myblob.name}"
f"Blob Size: {myblob.length} bytes")
# DO NOT include azure-functions-worker in this file
# The Python Worker is managed by Azure Functions platform
# Manually managing azure-functions-worker may cause unexpected issues
azure-functions
-f https://download.pytorch.org/whl/torch_stable.html
torch==1.13.1+cpu
torchvision==0.14.1+cpu
torchaudio==0.13.1
sentence_transformers==2.2.2
langchain==0.0.274
qdrant_client==1.2.0
pypdf==3.9.0
Several customers reported this issue here, which was closed with no answer. https://github.com/Azure/azure-functions-python-worker/issues/1262 Please kindly look in and suggest.
Tagging you from the closed issue where the MS team hasn’t been responding. @Otimkev @andrewmmm @jsm-NK @aadamsx @JarroVGIT @SiddheshDesai06
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 51 (8 by maintainers)
Plus one.
It is very frustrating to debug issues that occur outside of the function definition.
For example, import errors, missing dependencies, or issues with the binding and trigger definitions.
We are essentially flying blind when trying to debug these problems.
Azure Functions should provide more access to logging that can lend a light to these issues.
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:
pip install --target=".python_packages/lib/site-packages" -r requirements.txtzip release.zip .python_packages ./* -rscm-do-build-during-deployment: falseenable-oryx-build: falseThis way you can still use the V2 programming model and can use Github Actions instead of VSCode to deploy to the Azure Function.
Why was this issue closed while this clearly is an ongoing issue? Is there an other topic where we can follow the progress on this issue?
I am having similar issues where …
Tried all possible plans but none of seams to work. I am currently using Python 3.10 and V2 function. All logs in deployment center doesn’t show any error.
My requirement function is : azure-functions
I had the same issue and found the actual error by opening
MyAzureFunction/Monitoring/Log Stream/Filesystem Logsand deploying the function.I saw an error that imports were broken even though VS code said deployment was “successful” and function did not appear. Fixed this error and now function appears.
EDIT:
Added more code and it no longer shows any other errors in that log stream and function does not appear…
I found the actual actual error by setting up WSL in VS code and running the function there. It immediately threw the error which azure eats up. It was a keras model which works in windows but doesn’t work in linux, I just re-saved this model using WSL, tested locally, and now functions appear in Azure.
Azure should just throw these errors instead of silencing them and saying that the deployment is successful…
TLDR: Use WSL to test your function locally
Hello Gavin, Yes this issue is still there. I’ve raised a support ticket with Azure. They are looking into this. There’s some issue with the Github Deployment for Azure Functions. For some reason its not installing the libraries from requirements.txt. I found this from logs because of the import issues. The code works locally well. If I deploy the code from locally to Azure Function that works, but the Github Deployment has some issue.
Will this issue ever be fixed by azure? I tried deploying the function app 15 times yesterday and its not visible on portal
Hi @niraj-rel I am from MSFT and deployed lot of function apps until this point. The error’s you are facing is common and frustrating. One reason I found is difference between the environment in the azure function app cloud to the local. So the trick is always to write everything in the function basis.
@pdthummar that has worked, thank you!
Please can you advise how and where we can look up that failures?
@pdthummar Thank you, that seems to work now!
I used the VSCode-created blueprint.py unmodified; perhaps it would be good for the auto-generated example to not cause such errors. It did ask for both the blueprint filename and the new function name, so that’s arguably on me, but perhaps the sample could call the azure.functions.Blueprint object (and the decorator) FILE_bp or something like that just to minimize the chance of conflict.
In any case, indicating some kind of error during the deployment process would be great.
Also, both app.register_functions() and app.register_blueprint() seem to work; is there a different/preference?
Thanks again!
Saw what, exactly? The issue in #1262 can have many causes. Do you built locally and do a ZIP deployment? Do you perform a remote build? I have a special repo with reproducible steps for the issue of ‘Functions not showing in Azure Portal’, and they all have the same issue: there is an unhandled exception raised in the root of your script or imports. The reason may vary:
pip installstep on a Windows machine, while deploying to a Linux machine and one of your dependencies was specifically downloaded for Windows;.pyfile withmy_var = os.environ('MYVAR')(this will raise aKeyErrorifMYVARdoesn’t exists);Etc. There are countless ways to induce this behavior and the only thing Microsoft has to do is to propagate the exception raised to Application Insight so we can actually see what is wrong.
If you have no idea what is wrong: pull everything in the scope of your function method. So, rather than doing this:
Try this:
Now call your function and see what exception you get. If you don’t get an exception, then at least you can move back the lines of code one by one to pinpoint which one is causing issues.