Make sure that the values you want to use (Max Retry, Min Delay, Max Delay) are set in your Application Settings in the Azure Portal or your local.settings.json file during local development. 2. In your local.settings.json, it would look something like this:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "your_storage_account_connection_string",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"MaxRetry": "10",
"MinDelay": "00:00:45",
"MaxDelay": "00:05:00"
// other settings if you have of course
}
}
Then in your Azure Function, use the %
syntax to reference these settings in the ExponentialBackoffRetry
attribute. For example:
[FunctionName("MyFunction")]
[ExponentialBackoffRetry("%MaxRetry%", "%MinDelay%", "%MaxDelay%")]
public async Task Run([CosmosDBTrigger(/*my trigger settings here*/)] ...)
{
// Write your code here
}
-
%MaxRetry%
,%MinDelay%
, and%MaxDelay%
are placeholders for the actual values in your application settings. Just extra info at runtime, AF will replace these placeholders with the corresponding values from your configuration.