Skip to content

Commit

Permalink
Revert "Setting up Azure Active cloud corresponding to service endpoi…
Browse files Browse the repository at this point in the history
…nt (#9003) (#9006)"

This reverts commit 8ebe8db.
  • Loading branch information
vineetmimrot committed Dec 12, 2018
1 parent 6c3c07b commit e815460
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
"loc.messages.FailedToLogout": "The following error occurred while logging out: %s",
"loc.messages.LoginFailed": "Azure login failed",
"loc.messages.ErrorInSettingUpSubscription": "Error in setting up subscription",
"loc.messages.SettingAzureConfigDir": "Setting AZURE_CONFIG_DIR env variable to: %s",
"loc.messages.SettingAzureCloud": "Setting active cloud to: %s"
"loc.messages.SettingAzureConfigDir": "Setting AZURE_CONFIG_DIR env variable to: %s"
}
19 changes: 6 additions & 13 deletions Tasks/AzureCLIV1/azureclitask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export class azureclitask {
tool = tl.tool(tl.which(scriptPath, true));
}
this.throwIfError(tl.execSync("az", "--version"));
// set az cli config dir
this.setConfigDirectory();
this.setAzureCloudBasedOnServiceEndpoint();
this.useGlobalConfig = tl.getBoolInput("useGlobalConfig");
this.loginAzure();

tool.line(args); // additional args should always call line. line() parses quoted arg strings
Expand Down Expand Up @@ -106,6 +104,7 @@ export class azureclitask {
private static isLoggedIn: boolean = false;
private static cliPasswordPath: string = null;
private static azCliConfigPath: string;
private static useGlobalConfig: boolean = true;

private static loginAzure() {
var connectedService: string = tl.getInput("connectedServiceNameARM", true);
Expand All @@ -132,6 +131,9 @@ export class azureclitask {
var tenantId: string = tl.getEndpointAuthorizationParameter(connectedService, "tenantid", false);
var subscriptionID: string = tl.getEndpointDataParameter(connectedService, "SubscriptionID", true);

// set az cli config dir
this.setConfigDirectory();

//login using svn
this.throwIfError(tl.execSync("az", "login --service-principal -u \"" + servicePrincipalId + "\" -p \"" + cliPassword + "\" --tenant \"" + tenantId + "\""), tl.loc("LoginFailed"));
this.isLoggedIn = true;
Expand All @@ -140,7 +142,7 @@ export class azureclitask {
}

private static setConfigDirectory(): void {
if (tl.getBoolInput("useGlobalConfig")) {
if (this.useGlobalConfig) {
return;
}

Expand All @@ -160,15 +162,6 @@ export class azureclitask {
}
}

private static setAzureCloudBasedOnServiceEndpoint(): void {
var connectedService: string = tl.getInput("connectedServiceNameARM", true);
var environment = tl.getEndpointDataParameter(connectedService, 'environment', true);
if(!!environment) {
console.log(tl.loc('SettingAzureCloud', environment));
this.throwIfError(tl.execSync("az", "cloud set -n " + environment));
}
}

private static logoutAzure() {
try {
tl.execSync("az", " account clear");
Expand Down
7 changes: 3 additions & 4 deletions Tasks/AzureCLIV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 1,
"Minor": 143,
"Patch": 5
"Patch": 4
},
"minimumAgentVersion": "2.0.0",
"instanceNameFormat": "Azure CLI $(scriptPath)",
Expand Down Expand Up @@ -94,7 +94,7 @@
"name": "useGlobalConfig",
"type": "boolean",
"label": "Use global Azure CLI configuration",
"defaultValue": "false",
"defaultValue": "true",
"required": false,
"helpMarkDown": "If this is false, this task will use its own separate [Azure CLI configuration directory](https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration?view=azure-cli-latest#cli-configuration-file). This can be used to run Azure CLI tasks in *parallel* releases",
"groupName": "advanced"
Expand Down Expand Up @@ -135,7 +135,6 @@
"FailedToLogout": "The following error occurred while logging out: %s",
"LoginFailed": "Azure login failed",
"ErrorInSettingUpSubscription": "Error in setting up subscription",
"SettingAzureConfigDir": "Setting AZURE_CONFIG_DIR env variable to: %s",
"SettingAzureCloud": "Setting active cloud to: %s"
"SettingAzureConfigDir": "Setting AZURE_CONFIG_DIR env variable to: %s"
}
}
7 changes: 3 additions & 4 deletions Tasks/AzureCLIV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 1,
"Minor": 143,
"Patch": 5
"Patch": 4
},
"minimumAgentVersion": "2.0.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -94,7 +94,7 @@
"name": "useGlobalConfig",
"type": "boolean",
"label": "ms-resource:loc.input.label.useGlobalConfig",
"defaultValue": "false",
"defaultValue": "true",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.useGlobalConfig",
"groupName": "advanced"
Expand Down Expand Up @@ -135,7 +135,6 @@
"FailedToLogout": "ms-resource:loc.messages.FailedToLogout",
"LoginFailed": "ms-resource:loc.messages.LoginFailed",
"ErrorInSettingUpSubscription": "ms-resource:loc.messages.ErrorInSettingUpSubscription",
"SettingAzureConfigDir": "ms-resource:loc.messages.SettingAzureConfigDir",
"SettingAzureCloud": "ms-resource:loc.messages.SettingAzureCloud"
"SettingAzureConfigDir": "ms-resource:loc.messages.SettingAzureConfigDir"
}
}

0 comments on commit e815460

Please sign in to comment.