An organization has a workflow that polls the status of a long-running data export job. The workflow is implemented using Python Azure Durable Functions.
The orchestrator function is defined as follows:
python
import azure.functions as func
import azure.durable_functions as df
import datetime
import time
my_app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@my_app.orchestration_trigger(context_name="context")
def export_monitor_orchestrator(context: df.DurableOrchestrationContext):
job_id = context.get_input()
expiry_time = datetime.datetime.utcnow() + datetime.timedelta(hours=2)
while datetime.datetime.utcnow() < expiry_time:
status = yield context.call_activity("CheckJobStatus", job_id)
if status == "Completed":
yield context.call_activity("SendSuccessAlert", job_id)
return "Finished"
time.sleep(300)
yield context.call_activity("SendTimeoutAlert", job_id)
return "Timeout"
The function app is hosted on an Azure Functions Consumption plan. During testing, the orchestration fails to complete successfully and frequently times out.
Which two modifications should you make to resolve the issues and ensure the orchestrator runs reliably? (Select two.)
- Replace the datetime.datetime.utcnow() calls with context.current_utc_datetime.Answer
- Replace time.sleep(300) with a durable timer using yield context.create_timer().Answer
- CChange the hosting plan of the Function App to a Premium or Dedicated (App Service) plan.
- DCall the status endpoint directly using a Python HTTP client library inside the orchestrator loop.