Very simply! I have a function app - function_app.py, trigger.py and init.py in the root
Its my first Azure Function App. if i run the two files separately, function_app.py, trigger.py, they both return the results. Trigger.py looks at a file on sharepoint and does some cleansing and reposts it back to sharepoint.
Trigger.py has a function called Trigger() and within that, the function connects to Sharepoint, looks at a file, then does some changes and then uploads it again. This does 100% work.
The problem lies with when i call it from the Function_App.py as I want to deploy this as a Azure Function App.
i've created a trigger. Runs fine; on deployment, it times out. When I debug, it gives the following
Found Python version 3.11.9 (py).
Azure Functions Core Tools
Core Tools Version: 4.0.7030 Commit hash: N/A +bb4c949899cd5659d6bfe8b92cc923453a2e8f88 (64-bit)
Function Runtime Version: 4.1037.0.23568
[2025-04-24T17:18:19.054Z] Requesting metadata from worker failed.
[2025-04-24T17:18:19.057Z] Microsoft.Azure.WebJobs.Script.Grpc: The operation has timed out.
The function_app
looks like below:
import azure.functions as func
import logging
import json
from azure.functions import HttpRequest, HttpResponse
from myFile import Trigger
app = func.FunctionApp()
@app.function_name(name="Trigger")
@app.route(route="myApp", auth_level=func.AuthLevel.ANONYMOUS)
def mytrigger(req: func.HttpRequest) -> func.HttpResponse:
try:
# Call the Trigger function
Trigger() # This runs the entire process you defined
# Return a success message
return func.HttpResponse(" process completed successfully.", status_code=200)
except Exception as e:
logging.error(f"Error executing process: {str(e)}")
return func.HttpResponse(f"An error occurred: {str(e)}", status_code=500)
If I don't import the file or call Trigger(), the function_app.py runs as normal and opens up the URL with the response. So, I don't understand why calling this within, is causing heartache.
The files are in the root of Project. I don't have them spread in different folders. Please someone tell me why something so simple is not working.
The decorator had a function name explicitly named Trigger.
I needed to create a folder in Azure Function App called Trigger and place my files inside this folder. I originally had them in the root.
Issue resolved on moving files into Trigger folder.