From 2a6a6401a91b55e2245fae78d318c402410d2bc6 Mon Sep 17 00:00:00 2001 From: Andy Neillans Date: Thu, 21 Nov 2024 20:17:34 +0000 Subject: [PATCH 1/2] Add a new parameter - sync-access-token --- .../Actions/AzureActions/BaseAzureAction.cs | 6 ++++++ .../Actions/AzureActions/PublishFunctionAppAction.cs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs b/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs index 00962bba5..5d3cc83fc 100644 --- a/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs +++ b/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs @@ -13,6 +13,7 @@ using Newtonsoft.Json.Linq; using static Colors.Net.StringStaticMethods; using Azure.Functions.Cli.Helpers; +using Microsoft.Identity.Client; namespace Azure.Functions.Cli.Actions.AzureActions { @@ -33,6 +34,7 @@ abstract class BaseAzureAction : BaseAction, IInitializableAction private const string _defaultManagementURL = Constants.DefaultManagementURL; public string AccessToken { get; set; } + public string SyncAccessToken { get; set; } public bool ReadStdin { get; set; } public string ManagementURL { get; set; } public string Subscription { get; private set; } @@ -43,6 +45,10 @@ public override ICommandLineParserResult ParseArgs(string[] args) .Setup("access-token") .WithDescription("Access token to use for performing authenticated azure actions") .Callback(t => AccessToken = t); + Parser + .Setup("sync-access-token") + .WithDescription("Access token to use for performing trigger sync azure action (if different to normal)") + .Callback(t => SyncAccessToken = t); Parser .Setup("access-token-stdin") .WithDescription("Read access token from stdin e.g: az account get-access-token | func ... --access-token-stdin") diff --git a/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs b/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs index a3f1a18df..092748a84 100644 --- a/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs +++ b/src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs @@ -648,7 +648,11 @@ await RetryHelper.Retry(async () => ColoredConsole.WriteLine(GetLogMessage("Syncing triggers...")); HttpResponseMessage response = null; // This SyncTriggers function calls the endpoint for linux syncTriggers - response = await AzureHelper.SyncTriggers(functionApp, AccessToken, ManagementURL); + if (string.IsNullOrEmpty(SyncAccessToken)) + { + SyncAccessToken = AccessToken; + } + response = await AzureHelper.SyncTriggers(functionApp, SyncAccessToken, ManagementURL); if (!response.IsSuccessStatusCode) { var errorMessage = $"Error calling sync triggers ({response.StatusCode}). "; From df3936f82594a5a509b26e01ae30f9d5f93b43f8 Mon Sep 17 00:00:00 2001 From: Andy Neillans Date: Thu, 21 Nov 2024 20:32:26 +0000 Subject: [PATCH 2/2] Remove unused usings --- .../Actions/AzureActions/BaseAzureAction.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs b/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs index 5d3cc83fc..c74e1bae9 100644 --- a/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs +++ b/src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs @@ -1,9 +1,7 @@ using System; -using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -using Azure.Functions.Cli.Arm; using Azure.Functions.Cli.Common; using static Azure.Functions.Cli.Common.OutputTheme; using Azure.Functions.Cli.Interfaces; @@ -11,9 +9,6 @@ using Fclp; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using static Colors.Net.StringStaticMethods; -using Azure.Functions.Cli.Helpers; -using Microsoft.Identity.Client; namespace Azure.Functions.Cli.Actions.AzureActions {