public static async Task WaitForFlexDeployment()

in src/Cli/func/Helpers/KuduLiteDeploymentHelpers.cs [51:89]


        public static async Task<DeployStatus> WaitForFlexDeployment(HttpClient client, Site functionApp)
        {
            ColoredConsole.WriteLine("Deployment in progress, please wait...");
            DeployStatus statusCode = DeployStatus.Pending;
            DateTime logLastUpdate = DateTime.MinValue;
            string id = null;

            while (string.IsNullOrEmpty(id))
            {
                await Task.Delay(TimeSpan.FromSeconds(Constants.KuduLiteDeploymentConstants.StatusRefreshSeconds));
                id = await GetLatestDeploymentId(client, functionApp);
            }

            while (statusCode != DeployStatus.Success && statusCode != DeployStatus.Failed && statusCode != DeployStatus.Unknown && statusCode != DeployStatus.Conflict && statusCode != DeployStatus.PartialSuccess)
            {
                try
                {
                    statusCode = await GetDeploymentStatusById(client, functionApp, id);
                }
                catch (HttpRequestException)
                {
                    return DeployStatus.Unknown;
                }

                await Task.Delay(TimeSpan.FromSeconds(Constants.KuduLiteDeploymentConstants.StatusRefreshSeconds));
            }

            // Safely printing logs after the status is confirmed.
            try
            {
                await DisplayDeploymentLog(client, functionApp, id, logLastUpdate);
            }
            catch (Exception)
            {
                // ignore the fetch log failure.
            }

            return statusCode;
        }