diff --git a/src/Cli/AzureCliLogin.ts b/src/Cli/AzureCliLogin.ts index ec557fe6..fc67fbff 100644 --- a/src/Cli/AzureCliLogin.ts +++ b/src/Cli/AzureCliLogin.ts @@ -17,6 +17,9 @@ export class AzureCliLogin { async login() { core.info(`Running Azure CLI Login.`); this.azPath = await io.which("az", true); + if (!this.azPath) { + throw new Error("Azure CLI is not found in the runner."); + } core.debug(`Azure CLI path: ${this.azPath}`); let output: string = ""; diff --git a/src/PowerShell/AzPSUtils.ts b/src/PowerShell/AzPSUtils.ts index 4b287cfd..b9f37884 100644 --- a/src/PowerShell/AzPSUtils.ts +++ b/src/PowerShell/AzPSUtils.ts @@ -71,6 +71,9 @@ export class AzPSUtils { }; let psPath: string = await io.which(AzPSConstants.PowerShell_CmdName, true); + if (!psPath) { + throw new Error("PowerShell is not found in the runner."); + } await exec.exec(`"${psPath}"`, ["-Command", psScript], options) if (commandStdErr) { throw new Error('Azure PowerShell login failed with errors.'); diff --git a/src/common/Utils.ts b/src/common/Utils.ts index 9a2734be..adb96d3b 100644 --- a/src/common/Utils.ts +++ b/src/common/Utils.ts @@ -14,7 +14,8 @@ export function setUserAgent(): void { export async function cleanupAzCLIAccounts(): Promise { let azPath = await io.which("az", true); if (!azPath) { - throw new Error("Azure CLI is not found in the runner."); + core.warning("Azure CLI is not found in the runner."); + return; } core.debug(`Azure CLI path: ${azPath}`); core.info("Clearing azure cli accounts from the local cache."); @@ -24,7 +25,8 @@ export async function cleanupAzCLIAccounts(): Promise { export async function cleanupAzPSAccounts(): Promise { let psPath: string = await io.which(AzPSConstants.PowerShell_CmdName, true); if (!psPath) { - throw new Error("PowerShell is not found in the runner."); + core.warning("PowerShell is not found in the runner."); + return; } core.debug(`PowerShell path: ${psPath}`); core.debug("Importing Azure PowerShell module.");