remove az login else block. bad merge. + tidy up some code
This commit is contained in:
parent
0d0c4a32af
commit
56641ce573
1 changed files with 8 additions and 7 deletions
15
src/main.ts
15
src/main.ts
|
|
@ -139,11 +139,7 @@ async function main() {
|
|||
await spnlogin.initialize();
|
||||
await spnlogin.login();
|
||||
}
|
||||
else {
|
||||
// login using az cli
|
||||
await executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||
await executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
||||
}
|
||||
|
||||
console.log("Login successful.");
|
||||
}
|
||||
catch (error) {
|
||||
|
|
@ -162,12 +158,17 @@ async function main() {
|
|||
}
|
||||
}
|
||||
|
||||
async function executeAzCliCommand(command: string, silent?: boolean, execOptions: any = {}, args: any = []) {
|
||||
async function executeAzCliCommand(
|
||||
command: string,
|
||||
silent?: boolean,
|
||||
execOptions: any = {},
|
||||
args: any = []) {
|
||||
|
||||
execOptions.silent = !!silent;
|
||||
try {
|
||||
await exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
||||
}
|
||||
catch(error) {
|
||||
catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue