Closed alexx087 closed 7 months ago
Thanks for reporting will check and update.
import logging
import datetime
import fastapi
from urllib import response
fast_app = fastapi.FastAPI()
@fast_app.get("/return_http_no_body")
async def return_http_no_body():
return response(content='test', media_type='text/plain', status_code=200)
app = func.AsgiFunctionApp(app=fast_app, http_auth_level=func.AuthLevel.ANONYMOUS)
@app.schedule(schedule="0 */5 * * * *", arg_name="mytimer", run_on_startup=True)
def http_trigger(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
@alexx087 , thanks for reporting! turned out asgiapplication does not have function_name as decorator, can you try this sample?
working for me both local and prod
@YunchuWang, I can also confirm this behavior. It happens when you add this decorator:
@app.function_name(name="<funcname>")
In #1284 you show an example where you have this decorator running locally, but in your above example this decorator is missing to rename the TimerTrigger function and this is what appears to cause it to break when running in Azure Functions.
Anytime I've attempted to add this decorator and deploy the code to Azure, the Function fails to load any functions and remains in a failed state.
I have developed a Python FastAPI Azure Function that includes both HTTP-triggered and timer-scheduled triggers. I followed this Azure sample code to create the FastAPI Python Azure Function: Azure Functions Python Create FastAPI App. Additionally, I implemented the timer-scheduled trigger using the code suggested in this GitHub issue: Azure/azure-functions-python-worker#1284.
Everything works fine when tested locally, but upon deploying to Azure Functions, an error occurs stating 'HTTP trigger not found'. Please help :)
Here are my application settings:![image](https://github.com/Azure/azure-functions-python-worker/assets/93475004/0508e61d-7181-4eda-a4d2-e5a136345a4c)