Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry Policy support for V2 #1253

Closed
2 tasks done
gavin-aguiar opened this issue Jun 6, 2023 · 3 comments
Closed
2 tasks done

Retry Policy support for V2 #1253

gavin-aguiar opened this issue Jun 6, 2023 · 3 comments
Assignees
Milestone

Comments

@gavin-aguiar
Copy link
Contributor

gavin-aguiar commented Jun 6, 2023

Tasks

Preview Give feedback
  1. SDKBreakingChange
@gavin-aguiar gavin-aguiar added this to the Sprint 0623 milestone Jun 6, 2023
@gavin-aguiar gavin-aguiar self-assigned this Jun 6, 2023
@vrdmr
Copy link
Member

vrdmr commented Jul 10, 2023

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

@vrdmr vrdmr closed this as completed Jul 10, 2023
@ogiel
Copy link

ogiel commented Feb 13, 2024

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.

@gavin-aguiar
Copy link
Contributor Author

Hi @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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants