|
1 | | -// Copyright (c) .NET Foundation. All rights reserved. |
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
2 | 2 | // Licensed under the MIT License. See LICENSE in the project root for license information. |
3 | 3 |
|
4 | 4 | using Azure.Functions.Cli.Arm; |
@@ -383,31 +383,43 @@ internal static async Task CheckFunctionHostStatusForFlex(Site functionApp, stri |
383 | 383 | functionAppReadyClient.DefaultRequestHeaders.Add("User-Agent", Constants.CliUserAgent); |
384 | 384 | functionAppReadyClient.DefaultRequestHeaders.Add("Accept", jsonContentType); |
385 | 385 |
|
| 386 | + var statusUri = new Uri($"https://{functionApp.HostName}/admin/host/status?code={masterKey}"); |
| 387 | + ColoredConsole.WriteLine($"Host status endpoint: {statusUri.GetLeftPart(UriPartial.Path)}"); |
| 388 | + |
386 | 389 | await RetryHelper.Retry( |
387 | 390 | async () => |
388 | 391 | { |
| 392 | + // Remove the header in case it already exists from a previous retry |
| 393 | + functionAppReadyClient.DefaultRequestHeaders.Remove("x-ms-request-id"); |
389 | 394 | functionAppReadyClient.DefaultRequestHeaders.Add("x-ms-request-id", Guid.NewGuid().ToString()); |
390 | | - var uri = new Uri($"https://{functionApp.HostName}/admin/host/status?code={masterKey}"); |
| 395 | + |
391 | 396 | var request = new HttpRequestMessage() |
392 | 397 | { |
393 | | - RequestUri = uri, |
| 398 | + RequestUri = statusUri, |
394 | 399 | Method = HttpMethod.Get |
395 | 400 | }; |
396 | 401 |
|
397 | 402 | var response = await functionAppReadyClient.SendAsync(request); |
398 | 403 | ColoredConsole.Write("."); |
399 | 404 |
|
| 405 | + string responseContent = await response.Content.ReadAsStringAsync(); |
| 406 | + |
400 | 407 | if (response.IsSuccessStatusCode) |
401 | 408 | { |
402 | 409 | ColoredConsole.WriteLine(" done"); |
| 410 | + ColoredConsole.WriteLine($"Host status: {responseContent}"); |
403 | 411 | } |
404 | 412 | else |
405 | 413 | { |
| 414 | + ColoredConsole.WriteLine($"Host status check failed\nReason Phrase: {response.ReasonPhrase}" + |
| 415 | + (!string.IsNullOrEmpty(responseContent) ? $"\nError response: {responseContent}" : string.Empty)); |
| 416 | + |
406 | 417 | throw new CliException($"The host didn't return success status. Returned: {response.StatusCode}"); |
407 | 418 | } |
408 | 419 | }, |
409 | | - 15, |
410 | | - TimeSpan.FromSeconds(3)); |
| 420 | + retryCount: 15, |
| 421 | + retryDelay: TimeSpan.FromSeconds(5), |
| 422 | + displayError: true); |
411 | 423 | } |
412 | 424 |
|
413 | 425 | public static async Task<Site> LoadSiteObjectAsync(Site site, string accessToken, string managementURL) |
|
0 commit comments