Skip to content

Retry Policy support for V2 #1253

Closed
Closed

Description

### Tasks
- [ ] https://github.com/Azure/azure-functions-python-worker/pull/1268
- [ ] https://github.com/Azure/azure-functions-python-library/pull/182

Activity

  1. vrdmr commented on Jul 10, 2023

    @vrdmr
    Member

    Tasks completed - waiting for release - should be part of 4.25

  2. ogiel commented on Feb 13, 2024

    @ogiel

    Could any example be given on how to use retry policies on V2 functions? Everything I try results in no functions shown in the function app:

    @app.retry(strategy="fixedDelay", max_retry_count="3", delay_interval="00:00:30")
    @app.schedule(
        schedule="* 0 * * * *", arg_name="myTimer", run_on_startup=True, use_monitor=False
    )
    def AzureMapsWeatherToADT(myTimer: func.TimerRequest) -> None:
    

    If i comment out the @app.retry() it works.

    Unfortunately I am unable to find any examples or documentation, or even references to possible options for the strategy in the python package. E.g. should strategy be fixedDelay or fixed_delay?

    Edit to make the confusion a bit more clear:

        def retry(self,
                  strategy: str,
                  max_retry_count: str,
                  delay_interval: Optional[str] = None,
                  minimum_interval: Optional[str] = None,
                  maximum_interval: Optional[str] = None,
                  setting_extra_fields: Dict[str, Any] = {},
                  ) -> Callable[..., Any]:
            """The retry decorator adds :class:`RetryPolicy` to the function
            settings object for building :class:`Function` object used in worker
            function indexing model. This is equivalent to defining RetryPolicy
            in the function.json which enables function to retry on failure.
            All optional fields will be given default value by function host when
            they are parsed by function host.
    
            Ref: https://aka.ms/azure_functions_retries
    
            :param strategy: The retry strategy to use.
            :param max_retry_count: The maximum number of retry attempts.
            :param delay_interval: The delay interval between retry attempts.
            :param minimum_interval: The minimum delay interval between retry
            attempts.
            :param maximum_interval: The maximum delay interval between retry
            attempts.
            :param setting_extra_fields: Keyword arguments for specifying
            additional setting fields.
            :return: Decorator function.
            """
    

    The URL in the docstring refers to a V1 function model documentation with camel case for things like maxRetryCount, which is converted to max_retry_count in Python (makes sense, but please add docs at least somewhere). Nowhere it states whether the input fixedDelay should now be turned into fixed_delay. Then we have the max_retry_count which is a number in the V1 model function.json files, but the V2 docstring states this has to be a string. It annoys me that I always have to blindly try all options with these things while all it takes is one simple example. Sorry for the outing of my frustration.

    WORKING EXAMPLE (for anyone referring to this thread later):

    @app.retry(strategy="fixed_delay", max_retry_count="3", delay_interval="00:00:30")
    @app.schedule(
        schedule="* 0 * * * *", arg_name="myTimer", run_on_startup=True, use_monitor=False
    )
    def AzureMapsWeatherToADT(myTimer: func.TimerRequest) -> None:
    

    Conclusion, all names are converted from pascal to pythonic snake case and integers are converted to strings containing... integers. Good luck.

  3. gavin-aguiar commented on Feb 13, 2024

    @gavin-aguiar
    CollaboratorAuthor

    Hi Giel (@ogiel), Thanks for the feedback and apologies for the confusion. As you mentioned, all names are snake cased. We'll definitely add some examples for retries with the v2 programming model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions