mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
Compare commits
1 Commits
v1.5.1
...
releases/v
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c88f01b0e |
33
.github/workflows/azure-login-negative.yml
vendored
33
.github/workflows/azure-login-negative.yml
vendored
@@ -347,7 +347,7 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
core.setFailed('Last action should fail but not. Please check it.')
|
core.setFailed('Last action should fail but not. Please check it.')
|
||||||
|
|
||||||
# SP1 is ignored and SP2 will be used for login, but it will fail since SP2 has no access to the given subscription
|
# Secret of SP1 in creds will be used to sign in SP2
|
||||||
- name: Login with both creds and individual parameters
|
- name: Login with both creds and individual parameters
|
||||||
id: login_12
|
id: login_12
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -382,37 +382,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.setFailed('Last action should fail but not. Please check it.')
|
core.setFailed('Last action should fail but not. Please check it.')
|
||||||
|
|
||||||
- name: Login with individual parameters, no subscription-id, no allow-no-subscriptions
|
|
||||||
id: login_14
|
|
||||||
continue-on-error: true
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
client-id: ${{ secrets.OIDC_SP2_CLIENT_ID }}
|
|
||||||
tenant-id: ${{ secrets.OIDC_SP2_TENANT_ID }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Check Last step failed
|
|
||||||
if: steps.login_14.outcome == 'success'
|
|
||||||
uses: actions/github-script@v3
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
core.setFailed('Last action should fail but not. Please check it.')
|
|
||||||
|
|
||||||
- name: Login with creds, no subscription-id, no allow-no-subscriptions
|
|
||||||
id: login_15
|
|
||||||
continue-on-error: true
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
creds: '{"clientId":"${{ secrets.OIDC_SP2_CLIENT_ID }}","clientSecret":"${{ secrets.SP2_CLIENT_SECRET }}","tenantId":"${{ secrets.OIDC_SP2_TENANT_ID }}"}'
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Check Last step failed
|
|
||||||
if: steps.login_15.outcome == 'success'
|
|
||||||
uses: actions/github-script@v3
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
core.setFailed('Last action should fail but not. Please check it.')
|
|
||||||
|
|
||||||
VMTest:
|
VMTest:
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
51
.github/workflows/azure-login-positive.yml
vendored
51
.github/workflows/azure-login-positive.yml
vendored
@@ -61,9 +61,10 @@ jobs:
|
|||||||
- name: Login with individual parameters
|
- name: Login with individual parameters
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
client-id: ${{ secrets.SP1_CLIENT_ID }}
|
client-id: ${{ secrets.OIDC_SP2_CLIENT_ID }}
|
||||||
tenant-id: ${{ secrets.SP1_TENANT_ID }}
|
tenant-id: ${{ secrets.OIDC_SP2_TENANT_ID }}
|
||||||
subscription-id: ${{ secrets.SP1_SUBSCRIPTION_ID }}
|
# subscription-id: ${{ secrets.OIDC_SP2_SUBSCRIPTION_ID }}
|
||||||
|
allow-no-subscriptions: true
|
||||||
enable-AzPSSession: true
|
enable-AzPSSession: true
|
||||||
|
|
||||||
- name: Run Azure Cli again
|
- name: Run Azure Cli again
|
||||||
@@ -175,29 +176,6 @@ jobs:
|
|||||||
throw "Not all checks passed!"
|
throw "Not all checks passed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Login with individual parameters, allow no subscription
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
client-id: ${{ secrets.SP1_CLIENT_ID }}
|
|
||||||
tenant-id: ${{ secrets.SP1_TENANT_ID}}
|
|
||||||
subscription-id: ${{ secrets.SP1_SUBSCRIPTION_ID }}
|
|
||||||
allow-no-subscriptions: true
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Run Azure Cli again
|
|
||||||
run: |
|
|
||||||
az account show --output none
|
|
||||||
|
|
||||||
- name: Run Azure PowerShell again
|
|
||||||
uses: azure/powershell@v1.2.0
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud'
|
|
||||||
if(-not $checkResult){
|
|
||||||
throw "Not all checks passed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Login with individual parameters, no subscription, allow no subscription
|
- name: Login with individual parameters, no subscription, allow no subscription
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -220,27 +198,6 @@ jobs:
|
|||||||
throw "Not all checks passed!"
|
throw "Not all checks passed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Login with creds, no subscription, allow no subscription
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
creds: '{"clientId":"${{ secrets.OIDC_SP2_CLIENT_ID }}","clientSecret":"${{ secrets.SP2_CLIENT_SECRET }}","tenantId":"${{ secrets.OIDC_SP2_TENANT_ID }}"}'
|
|
||||||
allow-no-subscriptions: true
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Run Azure Cli
|
|
||||||
run: |
|
|
||||||
az account show --output none
|
|
||||||
|
|
||||||
- name: Run Azure PowerShell
|
|
||||||
uses: azure/powershell@v1.2.0
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud'
|
|
||||||
if(-not $checkResult){
|
|
||||||
throw "Not all checks passed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
VMTest:
|
VMTest:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -74,29 +74,16 @@ describe("LoginConfig Test", () => {
|
|||||||
await testCreds(creds1);
|
await testCreds(creds1);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('initialize with creds, lack of subscriptionId, but allowNoSubscriptionsLogin=true', async () => {
|
test('initialize with creds, lack of subscriptionId', async () => {
|
||||||
let creds1 = {
|
let creds1 = {
|
||||||
'clientId': 'client-id',
|
'clientId': 'client-id',
|
||||||
'clientSecret': 'client-secret',
|
'clientSecret': 'client-secret',
|
||||||
'tenantId': 'tenant-id',
|
'tenantId': 'tenant-id',
|
||||||
// 'subscriptionId': 'subscription-id'
|
// 'subscriptionId': 'subscription-id'
|
||||||
}
|
}
|
||||||
setEnv('environment', 'azurecloud');
|
await testCreds(creds1);
|
||||||
setEnv('enable-AzPSSession', 'true');
|
|
||||||
setEnv('allow-no-subscriptions', 'true');
|
|
||||||
setEnv('auth-type', 'SERVICE_PRINCIPAL');
|
|
||||||
setEnv('creds', JSON.stringify(creds1));
|
|
||||||
let loginConfig = new LoginConfig();
|
|
||||||
await loginConfig.initialize();
|
|
||||||
expect(loginConfig.environment).toBe("azurecloud");
|
|
||||||
expect(loginConfig.enableAzPSSession).toBeTruthy();
|
|
||||||
expect(loginConfig.allowNoSubscriptionsLogin).toBeTruthy();
|
|
||||||
expect(loginConfig.authType).toBe("SERVICE_PRINCIPAL");
|
|
||||||
expect(loginConfig.servicePrincipalId).toBe("client-id");
|
|
||||||
expect(loginConfig.servicePrincipalSecret).toBe("client-secret");
|
|
||||||
expect(loginConfig.tenantId).toBe("tenant-id");
|
|
||||||
expect(loginConfig.subscriptionId).toBe("");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('initialize with creds', async () => {
|
test('initialize with creds', async () => {
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ class AzureCliLogin {
|
|||||||
};
|
};
|
||||||
yield this.executeAzCliCommand(["--version"], true, execOptions);
|
yield this.executeAzCliCommand(["--version"], true, execOptions);
|
||||||
core.debug(`Azure CLI version used:\n${output}`);
|
core.debug(`Azure CLI version used:\n${output}`);
|
||||||
yield this.executeAzCliCommand(["account", "clear"], true, execOptions);
|
|
||||||
this.setAzurestackEnvIfNecessary();
|
this.setAzurestackEnvIfNecessary();
|
||||||
yield this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false);
|
yield this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false);
|
||||||
core.info(`Done setting cloud: "${this.loginConfig.environment}"`);
|
core.info(`Done setting cloud: "${this.loginConfig.environment}"`);
|
||||||
@@ -154,14 +153,15 @@ class AzureCliLogin {
|
|||||||
args.push("--allow-no-subscriptions");
|
args.push("--allow-no-subscriptions");
|
||||||
}
|
}
|
||||||
yield this.executeAzCliCommand(args, true, this.loginOptions);
|
yield this.executeAzCliCommand(args, true, this.loginOptions);
|
||||||
if (this.loginConfig.subscriptionId) {
|
yield this.setSubscription();
|
||||||
yield this.setSubscription();
|
|
||||||
}
|
|
||||||
core.info(`Azure CLI login succeeds by using ${methodName}.`);
|
core.info(`Azure CLI login succeeds by using ${methodName}.`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setSubscription() {
|
setSubscription() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (this.loginConfig.allowNoSubscriptionsLogin) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let args = ["account", "set", "--subscription", this.loginConfig.subscriptionId];
|
let args = ["account", "set", "--subscription", this.loginConfig.subscriptionId];
|
||||||
yield this.executeAzCliCommand(args, true, this.loginOptions);
|
yield this.executeAzCliCommand(args, true, this.loginOptions);
|
||||||
core.info("Subscription is set successfully.");
|
core.info("Subscription is set successfully.");
|
||||||
@@ -187,7 +187,7 @@ function defaultExecOptions() {
|
|||||||
if (error && error.trim().length !== 0 && !startsWithWarning) {
|
if (error && error.trim().length !== 0 && !startsWithWarning) {
|
||||||
if (startsWithError) {
|
if (startsWithError) {
|
||||||
//removing the keyword 'ERROR' to avoid duplicates while throwing error
|
//removing the keyword 'ERROR' to avoid duplicates while throwing error
|
||||||
error = error.slice(7);
|
error = error.slice(5);
|
||||||
}
|
}
|
||||||
core.error(error);
|
core.error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ class LoginConfig {
|
|||||||
this.tenantId = this.tenantId ? this.tenantId : secrets.getSecret("$.tenantId", false);
|
this.tenantId = this.tenantId ? this.tenantId : secrets.getSecret("$.tenantId", false);
|
||||||
this.subscriptionId = this.subscriptionId ? this.subscriptionId : secrets.getSecret("$.subscriptionId", false);
|
this.subscriptionId = this.subscriptionId ? this.subscriptionId : secrets.getSecret("$.subscriptionId", false);
|
||||||
this.resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
this.resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
||||||
if (!this.servicePrincipalId || !this.servicePrincipalSecret || !this.tenantId) {
|
if (!this.servicePrincipalId || !this.servicePrincipalSecret || !this.tenantId || !this.subscriptionId) {
|
||||||
throw new Error("Not all parameters are provided in 'creds'. Double-check if all keys are defined in 'creds': 'clientId', 'clientSecret', 'tenantId'.");
|
throw new Error("Not all parameters are provided in 'creds'. Double-check if all keys are defined in 'creds': 'clientId', 'clientSecret', 'subscriptionId', 'tenantId'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getFederatedToken() {
|
getFederatedToken() {
|
||||||
|
|||||||
8
node_modules/.package-lock.json
generated
vendored
8
node_modules/.package-lock.json
generated
vendored
@@ -1117,11 +1117,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/actions-secret-parser": {
|
"node_modules/actions-secret-parser": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.3.tgz",
|
||||||
"integrity": "sha512-gDAB8GK2Vj9CN5r97DZlmpxqrMcpAGKGWiIY3hpFhJMieLpl3K3ocVR49/Q4ANaA5a/2wNRE3Qng+x0K8mkmkQ==",
|
"integrity": "sha512-+iGlMSsE/cbxDaEZlqR0NUjn35DckMYsdYFwVeZ7JRbtyO/AiBKnaScKkzkHSoiZ4nEPTdIHtMpRGVgoeVYX+A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.1.10",
|
"@actions/core": "^1.1.3",
|
||||||
"jsonpath": "^1.0.2",
|
"jsonpath": "^1.0.2",
|
||||||
"xmldom": "^0.1.27",
|
"xmldom": "^0.1.27",
|
||||||
"xpath": "0.0.27"
|
"xpath": "0.0.27"
|
||||||
|
|||||||
1
node_modules/actions-secret-parser/index.js
generated
vendored
1
node_modules/actions-secret-parser/index.js
generated
vendored
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.SecretParser = exports.FormatType = void 0;
|
|
||||||
var core = require('@actions/core');
|
var core = require('@actions/core');
|
||||||
var jp = require('jsonpath');
|
var jp = require('jsonpath');
|
||||||
var xpath = require('xpath');
|
var xpath = require('xpath');
|
||||||
|
|||||||
69
node_modules/actions-secret-parser/package.json
generated
vendored
69
node_modules/actions-secret-parser/package.json
generated
vendored
@@ -1,35 +1,34 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-secret-parser",
|
"name": "actions-secret-parser",
|
||||||
"version": "1.0.4",
|
"version": "1.0.3",
|
||||||
"description": "Parse and set repository secrets",
|
"description": "Parse and set repository secrets",
|
||||||
"main": "index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"copypackage": "copy package.json lib",
|
"copypackage": "copy package.json lib",
|
||||||
"dist": "npm run build && npm run copypackage && cd lib && npm publish"
|
"dist": "npm run build && npm run copypackage && cd lib && npm publish"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"secret",
|
"secret",
|
||||||
"actions"
|
"actions"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/Microsoft/pipelines-appservice-lib.git"
|
"url": "git+https://github.com/Microsoft/pipelines-appservice-lib.git"
|
||||||
},
|
},
|
||||||
"author": "Sumiran Aggarwal <suaggar@microsoft.com>",
|
"author": "Sumiran Aggarwal <suaggar@microsoft.com>",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/Microsoft/pipelines-appservice-lib/issues"
|
"url": "https://github.com/Microsoft/pipelines-appservice-lib/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Microsoft/pipelines-appservice-lib/tree/master/packages/utility",
|
"homepage": "https://github.com/Microsoft/pipelines-appservice-lib/tree/master/packages/utility",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.11.17",
|
"typescript": "^3.6.3"
|
||||||
"typescript": "^3.6.3"
|
},
|
||||||
},
|
"dependencies": {
|
||||||
"dependencies": {
|
"@actions/core": "^1.1.3",
|
||||||
"@actions/core": "^1.1.10",
|
"jsonpath": "^1.0.2",
|
||||||
"jsonpath": "^1.0.2",
|
"xmldom": "^0.1.27",
|
||||||
"xmldom": "^0.1.27",
|
"xpath": "0.0.27"
|
||||||
"xpath": "0.0.27"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
18
package-lock.json
generated
18
package-lock.json
generated
@@ -12,7 +12,7 @@
|
|||||||
"@actions/core": "1.9.1",
|
"@actions/core": "1.9.1",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"actions-secret-parser": "^1.0.4",
|
"actions-secret-parser": "^1.0.2",
|
||||||
"package-lock": "^1.0.3"
|
"package-lock": "^1.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -1137,11 +1137,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/actions-secret-parser": {
|
"node_modules/actions-secret-parser": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.3.tgz",
|
||||||
"integrity": "sha512-gDAB8GK2Vj9CN5r97DZlmpxqrMcpAGKGWiIY3hpFhJMieLpl3K3ocVR49/Q4ANaA5a/2wNRE3Qng+x0K8mkmkQ==",
|
"integrity": "sha512-+iGlMSsE/cbxDaEZlqR0NUjn35DckMYsdYFwVeZ7JRbtyO/AiBKnaScKkzkHSoiZ4nEPTdIHtMpRGVgoeVYX+A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.1.10",
|
"@actions/core": "^1.1.3",
|
||||||
"jsonpath": "^1.0.2",
|
"jsonpath": "^1.0.2",
|
||||||
"xmldom": "^0.1.27",
|
"xmldom": "^0.1.27",
|
||||||
"xpath": "0.0.27"
|
"xpath": "0.0.27"
|
||||||
@@ -4741,11 +4741,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"actions-secret-parser": {
|
"actions-secret-parser": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.3.tgz",
|
||||||
"integrity": "sha512-gDAB8GK2Vj9CN5r97DZlmpxqrMcpAGKGWiIY3hpFhJMieLpl3K3ocVR49/Q4ANaA5a/2wNRE3Qng+x0K8mkmkQ==",
|
"integrity": "sha512-+iGlMSsE/cbxDaEZlqR0NUjn35DckMYsdYFwVeZ7JRbtyO/AiBKnaScKkzkHSoiZ4nEPTdIHtMpRGVgoeVYX+A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.1.10",
|
"@actions/core": "^1.1.3",
|
||||||
"jsonpath": "^1.0.2",
|
"jsonpath": "^1.0.2",
|
||||||
"xmldom": "^0.1.27",
|
"xmldom": "^0.1.27",
|
||||||
"xpath": "0.0.27"
|
"xpath": "0.0.27"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"@actions/core": "1.9.1",
|
"@actions/core": "1.9.1",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"actions-secret-parser": "^1.0.4",
|
"actions-secret-parser": "^1.0.2",
|
||||||
"package-lock": "^1.0.3"
|
"package-lock": "^1.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,6 @@ export class AzureCliLogin {
|
|||||||
await this.executeAzCliCommand(["--version"], true, execOptions);
|
await this.executeAzCliCommand(["--version"], true, execOptions);
|
||||||
core.debug(`Azure CLI version used:\n${output}`);
|
core.debug(`Azure CLI version used:\n${output}`);
|
||||||
|
|
||||||
await this.executeAzCliCommand(["account", "clear"], true, execOptions);
|
|
||||||
|
|
||||||
this.setAzurestackEnvIfNecessary();
|
this.setAzurestackEnvIfNecessary();
|
||||||
|
|
||||||
await this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false);
|
await this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false);
|
||||||
@@ -128,13 +126,14 @@ export class AzureCliLogin {
|
|||||||
args.push("--allow-no-subscriptions");
|
args.push("--allow-no-subscriptions");
|
||||||
}
|
}
|
||||||
await this.executeAzCliCommand(args, true, this.loginOptions);
|
await this.executeAzCliCommand(args, true, this.loginOptions);
|
||||||
if (this.loginConfig.subscriptionId) {
|
await this.setSubscription();
|
||||||
await this.setSubscription();
|
|
||||||
}
|
|
||||||
core.info(`Azure CLI login succeeds by using ${methodName}.`);
|
core.info(`Azure CLI login succeeds by using ${methodName}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSubscription() {
|
async setSubscription() {
|
||||||
|
if (this.loginConfig.allowNoSubscriptionsLogin) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let args = ["account", "set", "--subscription", this.loginConfig.subscriptionId];
|
let args = ["account", "set", "--subscription", this.loginConfig.subscriptionId];
|
||||||
await this.executeAzCliCommand(args, true, this.loginOptions);
|
await this.executeAzCliCommand(args, true, this.loginOptions);
|
||||||
core.info("Subscription is set successfully.");
|
core.info("Subscription is set successfully.");
|
||||||
@@ -161,7 +160,7 @@ function defaultExecOptions(): exec.ExecOptions {
|
|||||||
if (error && error.trim().length !== 0 && !startsWithWarning) {
|
if (error && error.trim().length !== 0 && !startsWithWarning) {
|
||||||
if (startsWithError) {
|
if (startsWithError) {
|
||||||
//removing the keyword 'ERROR' to avoid duplicates while throwing error
|
//removing the keyword 'ERROR' to avoid duplicates while throwing error
|
||||||
error = error.slice(7);
|
error = error.slice(5);
|
||||||
}
|
}
|
||||||
core.error(error);
|
core.error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ export class LoginConfig {
|
|||||||
this.tenantId = this.tenantId ? this.tenantId : secrets.getSecret("$.tenantId", false);
|
this.tenantId = this.tenantId ? this.tenantId : secrets.getSecret("$.tenantId", false);
|
||||||
this.subscriptionId = this.subscriptionId ? this.subscriptionId : secrets.getSecret("$.subscriptionId", false);
|
this.subscriptionId = this.subscriptionId ? this.subscriptionId : secrets.getSecret("$.subscriptionId", false);
|
||||||
this.resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
this.resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
||||||
if (!this.servicePrincipalId || !this.servicePrincipalSecret || !this.tenantId) {
|
if (!this.servicePrincipalId || !this.servicePrincipalSecret || !this.tenantId || !this.subscriptionId) {
|
||||||
throw new Error("Not all parameters are provided in 'creds'. Double-check if all keys are defined in 'creds': 'clientId', 'clientSecret', 'tenantId'.");
|
throw new Error("Not all parameters are provided in 'creds'. Double-check if all keys are defined in 'creds': 'clientId', 'clientSecret', 'subscriptionId', 'tenantId'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user