mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
Compare commits
4 Commits
v1.1.1
...
users/aksm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f001fbb0b9 | ||
|
|
b4fcf5d07d | ||
|
|
e2ec7a0d58 | ||
|
|
af38bb3818 |
@@ -5,7 +5,7 @@ jest.mock('../../src/PowerShell/Utilities/PowerShellToolRunner');
|
|||||||
let spnlogin: ServicePrincipalLogin;
|
let spnlogin: ServicePrincipalLogin;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
spnlogin = new ServicePrincipalLogin("servicePrincipalID", "servicePrinicipalkey", "tenantId", "subscriptionId");
|
spnlogin = new ServicePrincipalLogin("servicePrincipalID", "servicePrinicipalkey", "tenantId", "subscriptionId", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
25
__tests__/PowerShell/Utilities/ScriptBuilder.test.ts
Normal file
25
__tests__/PowerShell/Utilities/ScriptBuilder.test.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import ScriptBuilder from "../../../src/PowerShell/Utilities/ScriptBuilder";
|
||||||
|
import Constants from "../../../src/PowerShell/Constants";
|
||||||
|
|
||||||
|
describe("Getting AzLogin PS script" , () => {
|
||||||
|
const scheme = Constants.ServicePrincipal;
|
||||||
|
let args: any = {
|
||||||
|
servicePrincipalId: "service-principal-id",
|
||||||
|
servicePrincipalKey: "service-principal-key",
|
||||||
|
environment: "environment",
|
||||||
|
scopeLevel: Constants.Subscription,
|
||||||
|
subscriptionId: "subId",
|
||||||
|
allowNoSubscriptionsLogin: true
|
||||||
|
}
|
||||||
|
|
||||||
|
test("PS script should not set context while passing allowNoSubscriptionsLogin as true", () => {
|
||||||
|
const loginScript = new ScriptBuilder().getAzPSLoginScript(scheme, "tenant-id", args);
|
||||||
|
expect(loginScript.includes("Set-AzContext -SubscriptionId")).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("PS script should set context while passing allowNoSubscriptionsLogin as false", () => {
|
||||||
|
args["allowNoSubscriptionsLogin"] = false;
|
||||||
|
const loginScript = new ScriptBuilder().getAzPSLoginScript(scheme, "tenant-id", args);
|
||||||
|
expect(loginScript.includes("Set-AzContext -SubscriptionId")).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -9,6 +9,10 @@ inputs:
|
|||||||
description: 'Set this value to true to enable Azure PowerShell Login in addition to Az CLI login'
|
description: 'Set this value to true to enable Azure PowerShell Login in addition to Az CLI login'
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
allow-no-subscriptions:
|
||||||
|
description: 'Set this value to true to enable support for accessing tenants without subscriptions'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
branding:
|
branding:
|
||||||
icon: 'login.svg'
|
icon: 'login.svg'
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
|
|||||||
@@ -25,11 +25,12 @@ const PowerShellToolRunner_1 = __importDefault(require("./Utilities/PowerShellTo
|
|||||||
const ScriptBuilder_1 = __importDefault(require("./Utilities/ScriptBuilder"));
|
const ScriptBuilder_1 = __importDefault(require("./Utilities/ScriptBuilder"));
|
||||||
const Constants_1 = __importDefault(require("./Constants"));
|
const Constants_1 = __importDefault(require("./Constants"));
|
||||||
class ServicePrincipalLogin {
|
class ServicePrincipalLogin {
|
||||||
constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId) {
|
constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin) {
|
||||||
this.servicePrincipalId = servicePrincipalId;
|
this.servicePrincipalId = servicePrincipalId;
|
||||||
this.servicePrincipalKey = servicePrincipalKey;
|
this.servicePrincipalKey = servicePrincipalKey;
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
this.subscriptionId = subscriptionId;
|
this.subscriptionId = subscriptionId;
|
||||||
|
this.allowNoSubscriptionsLogin = allowNoSubscriptionsLogin;
|
||||||
}
|
}
|
||||||
initialize() {
|
initialize() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@@ -54,7 +55,8 @@ class ServicePrincipalLogin {
|
|||||||
servicePrincipalKey: this.servicePrincipalKey,
|
servicePrincipalKey: this.servicePrincipalKey,
|
||||||
subscriptionId: this.subscriptionId,
|
subscriptionId: this.subscriptionId,
|
||||||
environment: ServicePrincipalLogin.environment,
|
environment: ServicePrincipalLogin.environment,
|
||||||
scopeLevel: ServicePrincipalLogin.scopeLevel
|
scopeLevel: ServicePrincipalLogin.scopeLevel,
|
||||||
|
allowNoSubscriptionsLogin: this.allowNoSubscriptionsLogin
|
||||||
};
|
};
|
||||||
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
||||||
yield PowerShellToolRunner_1.default.init();
|
yield PowerShellToolRunner_1.default.init();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ScriptBuilder {
|
|||||||
command += `Connect-AzAccount -ServicePrincipal -Tenant '${tenantId}' -Credential \
|
command += `Connect-AzAccount -ServicePrincipal -Tenant '${tenantId}' -Credential \
|
||||||
(New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString '${args.servicePrincipalKey.replace("'", "''")}' -AsPlainText -Force))) \
|
(New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString '${args.servicePrincipalKey.replace("'", "''")}' -AsPlainText -Force))) \
|
||||||
-Environment '${args.environment}' | out-null;`;
|
-Environment '${args.environment}' | out-null;`;
|
||||||
if (args.scopeLevel === Constants_1.default.Subscription) {
|
if (args.scopeLevel === Constants_1.default.Subscription && !args.allowNoSubscriptionsLogin) {
|
||||||
command += `Set-AzContext -SubscriptionId '${args.subscriptionId}' -TenantId '${tenantId}' | out-null;`;
|
command += `Set-AzContext -SubscriptionId '${args.subscriptionId}' -TenantId '${tenantId}' | out-null;`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
lib/main.js
42
lib/main.js
@@ -17,7 +17,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const crypto = __importStar(require("crypto"));
|
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const actions_secret_parser_1 = require("actions-secret-parser");
|
const actions_secret_parser_1 = require("actions-secret-parser");
|
||||||
@@ -30,14 +29,24 @@ function main() {
|
|||||||
try {
|
try {
|
||||||
// Set user agent variable
|
// Set user agent variable
|
||||||
var isAzCLISuccess = false;
|
var isAzCLISuccess = false;
|
||||||
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
|
let usrAgentRepo = `${process.env.GITHUB_REPOSITORY}`;
|
||||||
let actionName = 'AzureLogin';
|
let actionName = 'AzureLogin';
|
||||||
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||||
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||||
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
|
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
|
||||||
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
||||||
azPath = yield io.which("az", true);
|
azPath = yield io.which("az", true);
|
||||||
yield executeAzCliCommand("--version");
|
let output = "";
|
||||||
|
const options = {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => {
|
||||||
|
output += data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
yield executeAzCliCommand("--version", true, options);
|
||||||
|
core.debug(`az cli version used:\n${output}`);
|
||||||
|
|
||||||
let creds = core.getInput('creds', { required: true });
|
let creds = core.getInput('creds', { required: true });
|
||||||
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
|
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
|
||||||
let servicePrincipalId = secrets.getSecret("$.clientId", false);
|
let servicePrincipalId = secrets.getSecret("$.clientId", false);
|
||||||
@@ -45,17 +54,28 @@ function main() {
|
|||||||
let tenantId = secrets.getSecret("$.tenantId", false);
|
let tenantId = secrets.getSecret("$.tenantId", false);
|
||||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !subscriptionId) {
|
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied.");
|
|
||||||
|
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||||
|
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||||
|
}
|
||||||
|
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
||||||
|
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
||||||
}
|
}
|
||||||
// Attempting Az cli login
|
// Attempting Az cli login
|
||||||
yield executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
console.log(`ak - clientId: ${servicePrincipalId}`);
|
||||||
yield executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
if (allowNoSubscriptionsLogin) {
|
||||||
|
yield executeAzCliCommand(`login --allow-no-subscriptions --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yield executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||||
|
yield executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
||||||
|
}
|
||||||
isAzCLISuccess = true;
|
isAzCLISuccess = true;
|
||||||
if (enableAzPSSession) {
|
if (enableAzPSSession) {
|
||||||
// Attempting Az PS login
|
// Attempting Az PS login
|
||||||
console.log(`Running Azure PS Login`);
|
console.log(`Running Azure PS Login`);
|
||||||
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId);
|
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin);
|
||||||
yield spnlogin.initialize();
|
yield spnlogin.initialize();
|
||||||
yield spnlogin.login();
|
yield spnlogin.login();
|
||||||
}
|
}
|
||||||
@@ -77,10 +97,12 @@ function main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function executeAzCliCommand(command, silent) {
|
|
||||||
|
function executeAzCliCommand(command, silent, options = {}) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
options.silent = !!silent;
|
||||||
try {
|
try {
|
||||||
yield exec.exec(`"${azPath}" ${command}`, [], { silent: !!silent });
|
yield exec.exec(`"${azPath}" ${command}`, [], options);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
|
|||||||
@@ -13,12 +13,18 @@ export class ServicePrincipalLogin implements IAzurePowerShellSession {
|
|||||||
servicePrincipalKey: string;
|
servicePrincipalKey: string;
|
||||||
tenantId: string;
|
tenantId: string;
|
||||||
subscriptionId: string;
|
subscriptionId: string;
|
||||||
|
allowNoSubscriptionsLogin: boolean;
|
||||||
|
|
||||||
constructor(servicePrincipalId: string, servicePrincipalKey: string, tenantId: string, subscriptionId: string) {
|
constructor(servicePrincipalId: string,
|
||||||
|
servicePrincipalKey: string,
|
||||||
|
tenantId: string,
|
||||||
|
subscriptionId: string,
|
||||||
|
allowNoSubscriptionsLogin: boolean) {
|
||||||
this.servicePrincipalId = servicePrincipalId;
|
this.servicePrincipalId = servicePrincipalId;
|
||||||
this.servicePrincipalKey = servicePrincipalKey;
|
this.servicePrincipalKey = servicePrincipalKey;
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
this.subscriptionId = subscriptionId;
|
this.subscriptionId = subscriptionId;
|
||||||
|
this.allowNoSubscriptionsLogin = allowNoSubscriptionsLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
async initialize() {
|
async initialize() {
|
||||||
@@ -42,7 +48,8 @@ export class ServicePrincipalLogin implements IAzurePowerShellSession {
|
|||||||
servicePrincipalKey: this.servicePrincipalKey,
|
servicePrincipalKey: this.servicePrincipalKey,
|
||||||
subscriptionId: this.subscriptionId,
|
subscriptionId: this.subscriptionId,
|
||||||
environment: ServicePrincipalLogin.environment,
|
environment: ServicePrincipalLogin.environment,
|
||||||
scopeLevel: ServicePrincipalLogin.scopeLevel
|
scopeLevel: ServicePrincipalLogin.scopeLevel,
|
||||||
|
allowNoSubscriptionsLogin: this.allowNoSubscriptionsLogin
|
||||||
}
|
}
|
||||||
const script: string = new ScriptBuilder().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
const script: string = new ScriptBuilder().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
||||||
await PowerShellToolRunner.init();
|
await PowerShellToolRunner.init();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default class ScriptBuilder {
|
|||||||
command += `Connect-AzAccount -ServicePrincipal -Tenant '${tenantId}' -Credential \
|
command += `Connect-AzAccount -ServicePrincipal -Tenant '${tenantId}' -Credential \
|
||||||
(New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString '${args.servicePrincipalKey.replace("'", "''")}' -AsPlainText -Force))) \
|
(New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString '${args.servicePrincipalKey.replace("'", "''")}' -AsPlainText -Force))) \
|
||||||
-Environment '${args.environment}' | out-null;`;
|
-Environment '${args.environment}' | out-null;`;
|
||||||
if (args.scopeLevel === Constants.Subscription) {
|
if (args.scopeLevel === Constants.Subscription && !args.allowNoSubscriptionsLogin) {
|
||||||
command += `Set-AzContext -SubscriptionId '${args.subscriptionId}' -TenantId '${tenantId}' | out-null;`;
|
command += `Set-AzContext -SubscriptionId '${args.subscriptionId}' -TenantId '${tenantId}' | out-null;`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
src/main.ts
40
src/main.ts
@@ -1,5 +1,4 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as crypto from "crypto";
|
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
// Set user agent variable
|
// Set user agent variable
|
||||||
var isAzCLISuccess = false;
|
var isAzCLISuccess = false;
|
||||||
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
|
let usrAgentRepo = `${process.env.GITHUB_REPOSITORY}`;
|
||||||
let actionName = 'AzureLogin';
|
let actionName = 'AzureLogin';
|
||||||
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||||
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||||
@@ -22,7 +21,16 @@ async function main() {
|
|||||||
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
||||||
|
|
||||||
azPath = await io.which("az", true);
|
azPath = await io.which("az", true);
|
||||||
await executeAzCliCommand("--version");
|
let output: string = "";
|
||||||
|
const options: any = {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer) => {
|
||||||
|
output += data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await executeAzCliCommand("--version", true, options);
|
||||||
|
core.debug(`az cli version used:\n${output}`);
|
||||||
|
|
||||||
let creds = core.getInput('creds', { required: true });
|
let creds = core.getInput('creds', { required: true });
|
||||||
let secrets = new SecretParser(creds, FormatType.JSON);
|
let secrets = new SecretParser(creds, FormatType.JSON);
|
||||||
@@ -31,17 +39,28 @@ async function main() {
|
|||||||
let tenantId = secrets.getSecret("$.tenantId", false);
|
let tenantId = secrets.getSecret("$.tenantId", false);
|
||||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !subscriptionId) {
|
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied.");
|
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||||
|
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
||||||
|
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
||||||
|
}
|
||||||
|
|
||||||
// Attempting Az cli login
|
// Attempting Az cli login
|
||||||
await executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
if (allowNoSubscriptionsLogin) {
|
||||||
await executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
await executeAzCliCommand(`login --allow-no-subscriptions --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||||
|
await executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
||||||
|
}
|
||||||
isAzCLISuccess = true;
|
isAzCLISuccess = true;
|
||||||
if (enableAzPSSession) {
|
if (enableAzPSSession) {
|
||||||
// Attempting Az PS login
|
// Attempting Az PS login
|
||||||
console.log(`Running Azure PS Login`);
|
console.log(`Running Azure PS Login`);
|
||||||
const spnlogin: ServicePrincipalLogin = new ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId);
|
const spnlogin: ServicePrincipalLogin = new ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin);
|
||||||
await spnlogin.initialize();
|
await spnlogin.initialize();
|
||||||
await spnlogin.login();
|
await spnlogin.login();
|
||||||
}
|
}
|
||||||
@@ -60,9 +79,10 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function executeAzCliCommand(command: string, silent?: boolean) {
|
async function executeAzCliCommand(command: string, silent?: boolean, options: any = {}) {
|
||||||
|
options.silent = !!silent;
|
||||||
try {
|
try {
|
||||||
await exec.exec(`"${azPath}" ${command}`, [], {silent: !!silent});
|
await exec.exec(`"${azPath}" ${command}`, [], options);
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user