Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARG Task Review comments from release branch #12079

Merged
merged 8 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@ export class ResourceGroup {

protected checkAndPrintPortalDeploymentURL(error: any) {
if(!!error && (error.statusCode < 400 || error.statusCode >= 500)) {
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
let url = this.getAzurePortalDeploymentURL();
if(url != null) {
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
}
}
}

Expand All @@ -595,7 +598,7 @@ export class ResourceGroup {
return portalUrl + subscriptionSpecificURL.replace(/\//g, '%2F');
} catch (error) {
tl.error(error);
return error;
return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureResourceGroupDeploymentV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 2,
"Minor": 163,
"Patch": 4
"Patch": 5
},
"demands": [],
"minimumAgentVersion": "2.119.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureResourceGroupDeploymentV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 2,
"Minor": 163,
"Patch": 4
"Patch": 5
},
"demands": [],
"minimumAgentVersion": "2.119.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ export class DeploymentScopeBase {

protected checkAndPrintPortalDeploymentURL(error: any) {
if((this.taskParameters.deploymentScope == "Resource Group" || this.taskParameters.deploymentScope == "Subscription") && (!!error && (error.statusCode < 400 || error.statusCode >= 500))) {
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
let url = this.getAzurePortalDeploymentURL();
if(url != null) {
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
}
}
}

Expand All @@ -124,7 +127,7 @@ export class DeploymentScopeBase {
return portalUrl + subscriptionSpecificURL.replace(/\//g, '%2F');
} catch (error) {
tl.error(error);
return error;
return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureResourceManagerTemplateDeploymentV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 3,
"Minor": 1,
"Patch": 14
"Patch": 15
},
"preview": "true",
"demands": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 3,
"Minor": 1,
"Patch": 14
"Patch": 15
},
"preview": "true",
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeploymentV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 3,
"Minor": 163,
"Patch": 2
"Patch": 3
},
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more information.",
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeploymentV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 3,
"Minor": 163,
"Patch": 2
"Patch": 3
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"minimumAgentVersion": "2.104.1",
Expand Down
9 changes: 8 additions & 1 deletion Tasks/Common/azure-arm-rest/azure-arm-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AzureRMEndpoint {
this.endpoint = null;
}

public async getEndpoint(): Promise<AzureEndpoint> {
public async getEndpoint(useGraphActiveDirectoryResource: boolean = false): Promise<AzureEndpoint> {
issacnitin marked this conversation as resolved.
Show resolved Hide resolved
if(!!this.endpoint) {
return this.endpoint;
}
Expand All @@ -43,6 +43,13 @@ export class AzureRMEndpoint {
azureKeyVaultDnsSuffix: tl.getEndpointDataParameter(this._connectedServiceName, 'AzureKeyVaultDnsSuffix', true),
} as AzureEndpoint;

if(useGraphActiveDirectoryResource) {
var activeDirectoryResourceId: string = tl.getEndpointDataParameter(this._connectedServiceName, 'graphUrl', true);
activeDirectoryResourceId = activeDirectoryResourceId != null ? activeDirectoryResourceId : "https://graph.windows.net/";
this.endpoint.url = activeDirectoryResourceId;
this.endpoint.activeDirectoryResourceID = activeDirectoryResourceId;
}

this.endpoint.authenticationType = tl.getEndpointAuthorizationParameter(this._connectedServiceName, 'authenticationType', true);

// if scheme is null, we assume the scheme to be ServicePrincipal
Expand Down
2 changes: 1 addition & 1 deletion Tasks/JavaToolInstallerV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 151,
"Patch": 9
"Patch": 10
},
"satisfies": [
"Java"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/JavaToolInstallerV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 151,
"Patch": 9
"Patch": 10
},
"satisfies": [
"Java"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/JenkinsDownloadArtifactsV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 1,
"Minor": 155,
"Patch": 5
"Patch": 6
},
"groups": [
{
Expand Down
2 changes: 1 addition & 1 deletion Tasks/JenkinsDownloadArtifactsV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 1,
"Minor": 155,
"Patch": 5
"Patch": 6
},
"groups": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class AzureSpnTemplateVariablesProvider implements definitions.IT
// if we are creating windows VM and SPN object-id is not available in service endpoint, fetch it from Graph endpoint
// NOP for nix
if(!spnObjectId && taskParameters.osType.toLowerCase().match(/^win/)) {
spnObjectId = await this.getServicePrincipalObjectId(await taskParameters.graphCredentials);
spnObjectId = await this.getServicePrincipalObjectId(await taskParameters.graphCredentialsPromise);
}

this._spnVariables.set(constants.TemplateVariableObjectIdName, spnObjectId);
Expand Down
25 changes: 6 additions & 19 deletions Tasks/PackerBuildV0/src/taskParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as path from "path";
import * as tl from "vsts-task-lib/task";
import * as constants from "./constants";
import * as utils from "./utilities";

import msRestAzure = require("azure-arm-rest/azure-arm-common");
import AzureRMEndpoint = require("azure-arm-rest/azure-arm-endpoint");

export default class TaskParameters {
public templateType: string;
Expand Down Expand Up @@ -34,7 +34,7 @@ export default class TaskParameters {

public imageUri: string;

public graphCredentials: msRestAzure.ApplicationTokenCredentials;
public graphCredentialsPromise: Promise<msRestAzure.ApplicationTokenCredentials>;

constructor() {
try {
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class TaskParameters {

this.deployScriptArguments = tl.getInput(constants.DeployScriptArgumentsInputName, false);

this.graphCredentials = this._getAzureADGraphCredentials(this.serviceEndpoint);
this.graphCredentialsPromise = this.getGraphCredentials(this.serviceEndpoint);
}

console.log(tl.loc("ParsingAdditionalBuilderParameters"));
Expand Down Expand Up @@ -114,21 +114,8 @@ export default class TaskParameters {
return inputPath;
}

private _getAzureADGraphCredentials(connectedService: string): msRestAzure.ApplicationTokenCredentials {
var servicePrincipalId: string = tl.getEndpointAuthorizationParameter(connectedService, "serviceprincipalid", false);
var servicePrincipalAuth: string;
let authType: string = tl.getEndpointAuthorizationParameter(connectedService, 'authenticationType', true);
if(authType == "spnCertificate") {
servicePrincipalAuth = tl.getEndpointAuthorizationParameter(connectedService, "serviceprincipalCertificate", false);
} else {
servicePrincipalAuth = tl.getEndpointAuthorizationParameter(connectedService, "serviceprincipalkey", false);
}
var tenantId: string = tl.getEndpointAuthorizationParameter(connectedService, "tenantid", false);
var envAuthorityUrl: string = tl.getEndpointDataParameter(connectedService, 'environmentauthorityurl', false);
envAuthorityUrl = (envAuthorityUrl != null) ? envAuthorityUrl : "https://login.windows.net/";
var activeDirectoryResourceId: string = tl.getEndpointDataParameter(connectedService, 'graphUrl', false);
activeDirectoryResourceId = (activeDirectoryResourceId != null) ? activeDirectoryResourceId : "https://graph.windows.net/";
var credentials = new msRestAzure.ApplicationTokenCredentials(servicePrincipalId, tenantId, servicePrincipalAuth, activeDirectoryResourceId, envAuthorityUrl, activeDirectoryResourceId, false);
return credentials;
private async getGraphCredentials(connectedService: string): Promise<msRestAzure.ApplicationTokenCredentials> {
var azureEndpoint = await new AzureRMEndpoint.AzureRMEndpoint(connectedService).getEndpoint(true);
return azureEndpoint.applicationTokenCredentials;
}
}
2 changes: 1 addition & 1 deletion Tasks/PackerBuildV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 32
"Patch": 33
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PackerBuildV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 32
"Patch": 33
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class AzureSpnTemplateVariablesProvider implements definitions.IT
// if we are creating windows VM and SPN object-id is not available in service endpoint, fetch it from Graph endpoint
// NOP for nix
if(!spnObjectId && taskParameters.osType.toLowerCase().match(/^win/)) {
spnObjectId = await this.getServicePrincipalObjectId(await taskParameters.graphCredentials);
spnObjectId = await this.getServicePrincipalObjectId(await taskParameters.graphCredentialsPromise);
}

this._spnVariables.set(constants.TemplateVariableObjectIdName, spnObjectId);
Expand Down
4 changes: 2 additions & 2 deletions Tasks/PackerBuildV1/src/taskParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class TaskParameters {
public imageUri: string;
public imageId: string;

public graphCredentials: Promise<msRestAzure.ApplicationTokenCredentials>;
public graphCredentialsPromise: Promise<msRestAzure.ApplicationTokenCredentials>;

constructor() {
try {
Expand Down Expand Up @@ -83,7 +83,7 @@ export default class TaskParameters {

this.deployScriptArguments = tl.getInput(constants.DeployScriptArgumentsInputName, false);

this.graphCredentials = this.getGraphCredentials(this.serviceEndpoint);
this.graphCredentialsPromise = this.getGraphCredentials(this.serviceEndpoint);
}
console.log(tl.loc("ParsingAdditionalBuilderParameters"));
this.additionalBuilderParameters = JSON.parse(tl.getInput("additionalBuilderParameters"));
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PackerBuildV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 1,
"Minor": 1,
"Patch": 10
"Patch": 11
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PackerBuildV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 1,
"Minor": 1,
"Patch": 10
"Patch": 11
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down