Is there a way to retry an API operation? C# Azure #10692
Unanswered
karpikpl
asked this question in
Pulumi in Practice
Replies: 2 comments 2 replies
-
I've ended up implementing that call outside of Pulumi. Hope it helps someone with similar issues. public Output<string> GetHostKeys(Output<string> rgName, Output<string> functionName)
{
return Output.Tuple(rgName, functionName).Apply(async t =>
{
var (resourceGroupName, siteName) = t;
var config = await GetClientConfig.InvokeAsync();
var result = await ApiClient
.WithRetry(count: 4, seconds: 5)
// Azure returns 400 BadRequest when Function App is not ready
.WithCustomRetryPolicy(HttpPolicyExtensions.HandleTransientHttpError().OrResult(http => http.StatusCode == System.Net.HttpStatusCode.BadRequest || http.StatusCode == System.Net.HttpStatusCode.NotFound))
.PostAsync<HostKeys>($"https://management.azure.com/subscriptions/{config.SubscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/host/default/listkeys?api-version=2022-03-01");
return result.Value.FunctionKeys.Key;
});
} I'm using open source library for making that call (that's also where my infra project is) I'm not closing the discussion because I would to get some feedback, if going custom with retries is the only solution. |
Beta Was this translation helpful? Give feedback.
0 replies
-
We're facing the same issue. It seems that the problem here is that the webapp is not ready soon enough to retrieve the keys. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an operation that sometimes works, sometimes fails in Azure and I have to re-run pulumi-up.
I tried wrapping
ListWebAppHostKeys
into some try/catch block but that doesn't seem to be possible.Ideally I would like to use Polly and deal with custom retries.
I can try making that List Host Keys with Azure SDK, but I'm not sure if that's going to work.
Beta Was this translation helpful? Give feedback.
All reactions