Using AsgiFunctionApp with another non-http function (QueueTrigger)
garoplin opened this issue · 11 comments
Is your question related to a specific version? If so, please specify:
Python 3.10, Python v2 model, Az Function 4+
What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)
Http + Queue Trigger
Question
I'm developing an application which will consist of 2 functions: Http and QueueTrigger. I want to use Http function with Fast Api. I wrote a simple code based on the documentation and it seems to be working, but i wanted to make sure that this is a proper solution. Namely I've created instance of an application: app = func.AsgiFunctionApp(app=fast_app, http_auth_level=func.AuthLevel.ANONYMOUS)
. Is it ok to use this app
object in QueueTrigger function?
The whole code:
fast_app = FastAPI()
@fast_app.get("/return_http_no_body")
async def return_http_no_body():
return Response(content='test', media_type="application/json")
app = func.AsgiFunctionApp(app=fast_app,
http_auth_level=func.AuthLevel.ANONYMOUS)
@app.function_name(name="QueueFunc")
@app.queue_trigger(arg_name="msg", queue_name="queue",
connection="storageAccountConnectionString") # Queue trigger
def test_function(msg: func.QueueMessage) -> None:
print(msg.get_body())```
I have the exact same use case: combining FastAPI based http triggers with other trigger types in a single function app. Is it possible/supported?
Thanks for informing will check and update you soon on this.
@gavin-aguiar pls comment
any updates on this?
@addeelnayyer Hi, AsgiFunctionApp should support other trigger/binding functions except for http functions (all http functions need to be defined under asgi not separately). Here is an example fastapi + timertrigger:
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.