Hello Egon,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Regarding your explanations and questions, I understand that your orchestration function does not pick up rightly after the activity function returns and it starts from the beginning.
Your Azure Durable Function code seems correct, but a few things you can check and adjust to ensure that your orchestrator function picks up right after the activity function returns and processes correctly. I made slight adjustment to your code as shown here:
import azure.functions as func
import azure.durable_functions as df
import logging.config
import logging
app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.orchestration_trigger(context_name="context")
def orchestrator_reading_a_book(context: df.DurableOrchestrationContext):
x = None
book = "Example_book"
page = 1
logging.warning(f'Head: Your Book: {book} at page {page}')
instance_id = context.instance_id
logging.warning(f'instance_id: {instance_id}')
while page < 4:
x = yield context.call_activity("flip_page", {
"book": book,
"page": page,
})
book = x.get("book")
page = x.get("page")
logging.warning(f'Lower: Your Book: {book} at page {page}')
logging.warning("You finished reading the book")
return("You finished reading the book")
@app.activity_trigger(input_name="context")
def flip_page(context):
if context:
book = context["book"]
page = context["page"]
page += 1
logging.warning(f"You flipped the page to page {page}")
else:
logging.warning(f"Page has not been flipped")
return {"book": book, "page": page}
# An HTTP-triggered function with a Durable Functions client binding
@app.route(route="orchestrators/{functionName}")
@app.durable_client_input(client_name="client")
async def http_start(req: func.HttpRequest, client):
function_name = req.route_params.get('functionName')
instance_id = await client.start_new(function_name)
response = client.create_check_status_response(req, instance_id)
return response
So, look deeper into your configuration and environment:
- Verify that the Durable Functions extension is installed and properly configured in your VS Code environment.
- Ensure that the function names in your
call_activity
method match the actual function names. - Ensure that logging is properly configured to capture the logs.
- Fix the typo in the logging statement for
instance_id
.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam