locked
Trouble using decorators in Azure functions RRS feed

  • Question

  • Hi,

    For a HTTP triggered azure function using python. I am prototyping a decorator that logs the duration of the execution of the function calls. I have tested the decorator on locally on an arbitrary function. However, getting it to work on the azure functions using the debug option i get the following error


    Worker failed to function id 45595f23-cc1b-4290-830d-c3d3639637b8.
    [2020-12-28T08:41:57.693Z] Result: Failure
    Exception: FunctionLoadError: cannot load the ETAEstimator function: the following parameters are declared in Python but not in function.json: {'args', 'kwargs'}
    Stack:   File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.6/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 273, in _handle__function_load_request
        function_id, func, func_request.metadata)
      File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.6/WINDOWS/X64\azure_functions_worker\functions.py", line 114, in add_function
        f'the following parameters are declared in Python but '
    .

    The decorator function that i have tested is below:

    def timeit(func):
        def timed(*args, **kwargs):
            ts = time.time()
            testis = func(*args, **kwargs)
            logging.info(
                "function with name %s has taken %s for execution ",
                func.__name__, time.time() - ts
            )
            return testis
        return timed
    Any help with the resolution of this issue will be greatly appreciated


    Monday, December 28, 2020 8:58 AM

Answers

  • I'd try asking for help over here.

    Azure on Q&A | Microsoft Docs

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Dave PatrickMVP Wednesday, December 30, 2020 10:06 PM
    • Marked as answer by Guido Franzke Monday, January 4, 2021 8:26 AM
    Monday, December 28, 2020 1:33 PM

All replies

  • forum migrated to mentioned below link please use this 

    https://docs.microsoft.com/en-us/answers/index.html

    marked as answer and vote if issue resolve

    Monday, December 28, 2020 9:46 AM
  • I'd try asking for help over here.

    Azure on Q&A | Microsoft Docs

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Dave PatrickMVP Wednesday, December 30, 2020 10:06 PM
    • Marked as answer by Guido Franzke Monday, January 4, 2021 8:26 AM
    Monday, December 28, 2020 1:33 PM