From bd15b4f198912cd5f024a035e9f2ee3b05a48213 Mon Sep 17 00:00:00 2001 From: MoChilia Date: Mon, 27 Nov 2023 16:26:50 +0800 Subject: [PATCH 1/2] logout at the beginning --- src/Cli/AzureCliLogin.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Cli/AzureCliLogin.ts b/src/Cli/AzureCliLogin.ts index fc67fbffc..c69bb75ec 100644 --- a/src/Cli/AzureCliLogin.ts +++ b/src/Cli/AzureCliLogin.ts @@ -34,6 +34,13 @@ export class AzureCliLogin { await this.executeAzCliCommand(["--version"], true, execOptions); core.debug(`Azure CLI version used:\n${output}`); + try { + await this.executeAzCliCommand(["logout"], true, execOptions); + } + catch (error) { + core.debug(`Ignore logout error: "${error}"`); + } + this.setAzurestackEnvIfNecessary(); await this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false); From df97fef4963fe077457eb5419af175b6322f0824 Mon Sep 17 00:00:00 2001 From: MoChilia Date: Mon, 27 Nov 2023 16:43:02 +0800 Subject: [PATCH 2/2] remove logout step in test case --- .github/workflows/azure-login-negative.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/azure-login-negative.yml b/.github/workflows/azure-login-negative.yml index 21bed1f0e..4f0362620 100644 --- a/.github/workflows/azure-login-negative.yml +++ b/.github/workflows/azure-login-negative.yml @@ -347,11 +347,6 @@ jobs: script: | core.setFailed('Last action should fail but not. Please check it.') - # logout first to avoid the conflict with SP1 - - name: Azure CLI logout - run: | - az logout - # SP1 is ignored and SP2 will be used for login, but it will fail since SP2 has no access to the given subscription - name: Login with both creds and individual parameters id: login_12