public override async Task RunAsync()

in src/Cli/func/Actions/AzureActions/LogStreamAction.cs [35:91]


        public override async Task RunAsync()
        {
            var subscriptions = await AzureHelper.GetSubscriptions(AccessToken, ManagementURL);
            ColoredConsole.WriteLine("Retrieving Function App...");
            var functionApp = await AzureHelper.GetFunctionApp(FunctionAppName, AccessToken, ManagementURL, Slot, Subscription, allSubs: subscriptions);

            if (UseBrowser)
            {
                await OpenLiveStreamInBrowser(functionApp, subscriptions);
                return;
            }

            if (functionApp.IsLinux && functionApp.IsDynamic)
            {
                throw new CliException("Log stream is not currently supported in Linux Consumption Apps. " +
                    "Please use --browser to open Azure Application Insights Live Stream in the Azure portal.");
            }

            using (var client = new HttpClient())
            {
                var isBasicAuthAllowed = true;

                try
                {
                    isBasicAuthAllowed = await AzureHelper.IsBasicAuthAllowedForSCM(functionApp, AccessToken, ManagementURL);
                }
                catch (Exception)
                {
                    // ignore: We don't want to fail the command on basic auth check. There is extremely low likelihood of getting the exception here.
                }

                if (isBasicAuthAllowed)
                {
                    var basicHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{functionApp.PublishingUserName}:{functionApp.PublishingPassword}"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", basicHeaderValue);
                }
                else
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
                }

                client.DefaultRequestHeaders.Add("User-Agent", Constants.CliUserAgent);
                var response = await client.GetStreamAsync(new Uri($"https://{functionApp.ScmUri}/api/logstream/application"));

                using (var reader = new StreamReader(response))
                {
                    var buffer = new char[4096];
                    var count = 0;
                    do
                    {
                        count = await reader.ReadAsync(buffer, 0, buffer.Length);
                        ColoredConsole.Write(new string(buffer.Take(count).ToArray()));
                    }
                    while (count != 0);
                }
            }
        }