Skip to content

Commit f6e4394

Browse files
authored
Add logs to CheckFunctionHostStatusForFlex (#4525)
1 parent 1a7af94 commit f6e4394

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
- Add exception details to error message during `func publish` (#4503)
1111
- Chocolatey: Update default installation to x64 (#4506)
1212
- Add console output encoding to support international chars (#4429)
13-
13+
- Add logs for host status checks during deployment of Flex Function Apps (#4525)

src/Cli/func/Helpers/AzureHelper.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using Azure.Functions.Cli.Arm;
@@ -383,31 +383,43 @@ internal static async Task CheckFunctionHostStatusForFlex(Site functionApp, stri
383383
functionAppReadyClient.DefaultRequestHeaders.Add("User-Agent", Constants.CliUserAgent);
384384
functionAppReadyClient.DefaultRequestHeaders.Add("Accept", jsonContentType);
385385

386+
var statusUri = new Uri($"https://{functionApp.HostName}/admin/host/status?code={masterKey}");
387+
ColoredConsole.WriteLine($"Host status endpoint: {statusUri.GetLeftPart(UriPartial.Path)}");
388+
386389
await RetryHelper.Retry(
387390
async () =>
388391
{
392+
// Remove the header in case it already exists from a previous retry
393+
functionAppReadyClient.DefaultRequestHeaders.Remove("x-ms-request-id");
389394
functionAppReadyClient.DefaultRequestHeaders.Add("x-ms-request-id", Guid.NewGuid().ToString());
390-
var uri = new Uri($"https://{functionApp.HostName}/admin/host/status?code={masterKey}");
395+
391396
var request = new HttpRequestMessage()
392397
{
393-
RequestUri = uri,
398+
RequestUri = statusUri,
394399
Method = HttpMethod.Get
395400
};
396401

397402
var response = await functionAppReadyClient.SendAsync(request);
398403
ColoredConsole.Write(".");
399404

405+
string responseContent = await response.Content.ReadAsStringAsync();
406+
400407
if (response.IsSuccessStatusCode)
401408
{
402409
ColoredConsole.WriteLine(" done");
410+
ColoredConsole.WriteLine($"Host status: {responseContent}");
403411
}
404412
else
405413
{
414+
ColoredConsole.WriteLine($"Host status check failed\nReason Phrase: {response.ReasonPhrase}" +
415+
(!string.IsNullOrEmpty(responseContent) ? $"\nError response: {responseContent}" : string.Empty));
416+
406417
throw new CliException($"The host didn't return success status. Returned: {response.StatusCode}");
407418
}
408419
},
409-
15,
410-
TimeSpan.FromSeconds(3));
420+
retryCount: 15,
421+
retryDelay: TimeSpan.FromSeconds(5),
422+
displayError: true);
411423
}
412424

413425
public static async Task<Site> LoadSiteObjectAsync(Site site, string accessToken, string managementURL)

0 commit comments

Comments
 (0)