the retry policy you defined will only be applied when there is an unhandled exception within your function code. If the error is being caught and handled within your code, the Azure Functions runtime will not consider it as a failure, and the retry policy won't be triggered.
To ensure that the retry policy is triggered when there is an error in the querying process, you should let the function throw an exception when an error occurs
for example
def main(mytimer: func.TimerRequest) -> None:
# Your logic to query the API and store data in the database
try:
# Your code to query the API and store data in the database
except Exception as e:
logging.error(f"An error occurred while querying the API: {e}")
raise