From 5ccbc18a3870d37cb4dd60a32a02cd21d52fe3db Mon Sep 17 00:00:00 2001 From: Michael Peng Date: Thu, 3 Feb 2022 16:32:42 -0500 Subject: [PATCH] Remove Function key by default when publishing (#2938) * Add no-key option to the PublishFunctionAppAction to remove function key from being displayed in the logs * Removes function keys by default when publishing --- .../Actions/AzureActions/PublishFunctionAppAction.cs | 8 +++++++- src/Azure.Functions.Cli/Helpers/AzureHelper.cs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs b/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs index f139d58e9..ef219bbfa 100644 --- a/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs +++ b/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs @@ -37,6 +37,7 @@ internal class PublishFunctionAppAction : BaseFunctionAppAction public bool ListIgnoredFiles { get; set; } public bool ListIncludedFiles { get; set; } public bool RunFromPackageDeploy { get; private set; } + public bool ShowKeys { get; set; } public bool Force { get; set; } public bool Csx { get; set; } public bool BuildNativeDeps { get; set; } @@ -95,6 +96,11 @@ public override ICommandLineParserResult ParseArgs(string[] args) .Setup("no-bundler") .WithDescription("[Deprecated] Skips generating a bundle when publishing python function apps with build-native-deps.") .Callback(nb => ColoredConsole.WriteLine(WarningColor($"Warning: Argument {AdditionalInfoColor("--no-bundler")} is deprecated and a no-op. Python function apps are not bundled anymore."))); + Parser + .Setup("show-keys") + .WithDescription("Adds function keys to the URLs displayed in the logs.") + .Callback(sk => ShowKeys = sk) + .SetDefault(false); Parser .Setup("additional-packages") .WithDescription("List of packages to install when building native dependencies. For example: \"python3-dev libevent-dev\"") @@ -505,7 +511,7 @@ private async Task PublishFunctionApp(Site functionApp, GitIgnoreParser ignorePa if (!(functionApp.IsLinux && functionApp.IsElasticPremium) && !(isFunctionAppDedicatedLinux && PublishBuildOption == BuildOption.Remote)) { - await AzureHelper.PrintFunctionsInfo(functionApp, AccessToken, ManagementURL, showKeys: true); + await AzureHelper.PrintFunctionsInfo(functionApp, AccessToken, ManagementURL, showKeys: ShowKeys); } } diff --git a/src/Azure.Functions.Cli/Helpers/AzureHelper.cs b/src/Azure.Functions.Cli/Helpers/AzureHelper.cs index d6f9f2226..aa4526b5f 100644 --- a/src/Azure.Functions.Cli/Helpers/AzureHelper.cs +++ b/src/Azure.Functions.Cli/Helpers/AzureHelper.cs @@ -391,7 +391,7 @@ public static async Task, string>> UpdateF } internal static async Task WaitUntilFunctionAppReadyAsync(Site functionApp, string accessToken, string managementURL, - bool showKeys, HttpMessageHandler messageHandler = null) + HttpMessageHandler messageHandler = null) { var masterKey = await GetMasterKeyAsync(functionApp.SiteId, accessToken, managementURL); @@ -457,7 +457,7 @@ public static async Task PrintFunctionsInfo(Site functionApp, string accessToken if (functionApp.IsKubeApp) { ColoredConsole.Write("Waiting for the functions host up and running "); - await WaitUntilFunctionAppReadyAsync(functionApp, accessToken, managementURL, showKeys); + await WaitUntilFunctionAppReadyAsync(functionApp, accessToken, managementURL); } ArmArrayWrapper functions = await GetFunctions(functionApp, accessToken, managementURL);