Durable Azure Function (python) weird behaviour

Viewed 23

I have a function that transfers folders across SharePoint sites. Because it can run for quite some time depending on the number of files to transfer I converted the azure function to a durable function.

Initially, all worked as expected until one time when many transfers failed due to the data not being on the source site. When the process looked up the folder on the source site it received ''Exception: 404 Client Error: Not Found''. I wasn't able to find the folder on the source site. But looking at the sink site the folder has been moved. The timestamp fits well with the azure function run. But the folder was not moved by the azure function.

Current setup:

Starter function

import logging
import azure.functions as func
import azure.durable_functions as df

async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse:
    try:
        req_body = req.get_json()
        logging.info(req_body)
    except ValueError:
        apps = None
    else:
        apps = req_body.get('apps')

    client = df.DurableOrchestrationClient(starter)
    x = [req.route_params["environment"], apps]
    instance_id = await client.start_new("orchestrator", None, x)
    logging.info(f"Started orchestration with ID = '{instance_id}'.")

    return client.create_check_status_response(req, instance_id)

Orchestrator

import logging
import json
import azure.functions as func
import azure.durable_functions as df

def orchestrator_function(context: df.DurableOrchestrationContext):
    environment, apps = context.get_input()

    if (environment == "production") and (not apps):
        result1 = yield context.call_activity('sp_folder_transfer_prod', None)
        return {"success": result1}
    elif (environment == "saffull") and (apps):
        result2 = yield context.call_activity('sp_folder_transfer_saffull', apps)
        return {"success": result2}
    else: 
        raise Exception('Process stopped')

main = df.Orchestrator.create(orchestrator_function)

sp_folder_transfer_prod init

import logging
from . import SAFTprod as saft
import traceback

def main(trigger):  
    try:
        saft.main_saft_prod()
        return True
    except:
        logging.error(traceback.format_exc())
        return False

I can't find anything that would indicate anything going wrong. The only weird thing I could find is a delay between the orchestrator function and the main function. In all other runs, there is no delay.

02:25:54 starter                   [duration 186ms]
02:25:55 orchestrator (1st run)    [duration 27ms]  
02:41:17 sp_folder_transfer_prod   [duration 4.27min]
02:45:35 orchestrator (2nd run)    [duration 86ms] 

There is a delay of 15min and 22s between the orchestrator being triggered and the start of the sp_folder_transfer_prod. Usually a run with the same number of folders to transfer would take about 20 min.

Any idea what is going on?

0 Answers
Related