private async Task GetRequestAsync()

in src/PSRule.Rules.Azure/Pipeline/Export/ExportDataContext.cs [124:167]


    private async Task<string> GetRequestAsync(string tenantId, string uri, bool ignoreNotFound)
    {
        var attempt = 0;
        using var client = GetClient(tenantId);
        try
        {
            do
            {
                attempt++;

                var response = await client.GetAsync(uri, _Cancel.Token);
                if (response.IsSuccessStatusCode)
                {
                    var json = await response.Content.ReadAsStringAsync();
                    return json;
                }
                else if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    if (!ignoreNotFound)
                        this.WarnFailedToGet(uri, response.StatusCode, _CorrelationId[0], await response.Content.ReadAsStringAsync());

                    return null;
                }
                else if (!ShouldRetry(response.StatusCode))
                {
                    this.WarnFailedToGet(uri, response.StatusCode, _CorrelationId[0], await response.Content.ReadAsStringAsync());
                    return null;
                }
                else
                {
                    this.WarnFailedToGet(uri, response.StatusCode, _CorrelationId[0], await response.Content.ReadAsStringAsync());
                    var retry = response.Headers.RetryAfter.Delta.GetValueOrDefault(_RetryInterval);
                    this.VerboseRetryIn(uri, retry, attempt);
                    Thread.Sleep(retry);
                }

            } while (attempt <= _RetryCount);
        }
        finally
        {
            // Do nothing
        }
        return null;
    }