Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding additional command line param of sync-access-token #4199

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
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;
using Colors.Net;
using Fclp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static Colors.Net.StringStaticMethods;
using Azure.Functions.Cli.Helpers;

namespace Azure.Functions.Cli.Actions.AzureActions
{
Expand All @@ -33,6 +29,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; }
Expand All @@ -43,6 +40,10 @@ public override ICommandLineParserResult ParseArgs(string[] args)
.Setup<string>("access-token")
.WithDescription("Access token to use for performing authenticated azure actions")
.Callback(t => AccessToken = t);
Parser
.Setup<string>("sync-access-token")
.WithDescription("Access token to use for performing trigger sync azure action (if different to normal)")
.Callback(t => SyncAccessToken = t);
Parser
.Setup<bool>("access-token-stdin")
.WithDescription("Read access token from stdin e.g: az account get-access-token | func ... --access-token-stdin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}). ";
Expand Down