I have 2 functions in my Azure function app using Queue Trigger: queue_trigger1, queue_trigger2. Running locally in VS Code.
The first function, queue_trigger1 located in function_app.py will send a message to queue_2, located in function_app2.py:
@app.queue_trigger(arg_name="azqueue", queue_name="queue_1",
connection="QueueConnectionString")
def queue_trigger1(azqueue: func.QueueMessage):
# do stuff, then send message to queue_2 to do more stuff
queue_client = QueueClient.from_connection_string(connect_str, queue_name="queue_2")
queue_client.send_message(azqueue.get_body().decode('utf-8'))
Running func start by itself will not run any code at all. So I did func start --functions queue_trigger1 and it successfully runs all the code in queue_trigger1, AND sends the message successfully to queue_2.
However, it ends there. Queue_2 is not triggered and nothing is done with the sent message, which is understandable because I only specified queue_trigger1 in my command.
I have tried running the code with func start --functions queue_trigger1 queue-trigger2 but then nothing runs again.
I realized that the naming of the function_app.py is the only thing that is recognized. If I instead put my queue_trigger2 code in function_app.py and run func start --functions queue-trigger2, then my queue_trigger2 code will then process the sent message (but I have to do this manually. I want queue_trigger2 to run automatically once message is sent from queue_trigger1)
Is this the wrong assumption? Is there a command I can use for me to run all the functions I have in my function app all at once while also separating my functions in different files?
In the Function V2 programming model outlined in the Microsoft Doc, streamlining folder and file management involves adding multiple Azure Function triggers within the same
function_app.pyfile, along with multiple input and output bindings.I tried the below code to trigger messages from queue1 to queue2 .
Code :
local.settings.json:
Output:
It ran successfully and it triggers the message from queue1 to queue2.