Skip to content

Commit

Permalink
Merge pull request #3256 from Microsoft/users/hiyada/Azurecli
Browse files Browse the repository at this point in the history
azurecli classic cert auth's service url picked from endpoint
  • Loading branch information
hiyadav authored Dec 16, 2016
2 parents 3624f36 + 86b8a8b commit 8c902da
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Tasks/AzureCLI/azureclitask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ export class azureclitask {
if (endpointAuth.scheme === "Certificate") {
var bytes = endpointAuth.parameters["certificate"];
var subscriptionId:string = tl.getEndpointDataParameter(connectedService, "SubscriptionId", true);
var serviceManagementUrl:string = tl.getEndpointUrl(connectedService, false);
const publishSettingFileName:string = path.join(os.tmpdir() ,"subscriptions" + new Date().getTime() + ".publishsettings");
this.createPublishSettingFile(subscriptionName, subscriptionId, bytes, publishSettingFileName);
this.createPublishSettingFile(subscriptionName, subscriptionId, bytes, serviceManagementUrl, publishSettingFileName);
var resultOfToolExecution = tl.execSync("azure", "account import \"" + publishSettingFileName + "\"");
this.deleteFile(publishSettingFileName);
this.throwIfError(resultOfToolExecution);
Expand Down Expand Up @@ -198,9 +199,9 @@ export class azureclitask {
}
}

private static createPublishSettingFile(subscriptionName:string, subscriptionId:string, certificate:string, publishSettingFileName:string): void {
private static createPublishSettingFile(subscriptionName:string, subscriptionId:string, certificate:string, serviceManagementUrl:string, publishSettingFileName:string): void {
//writing the data to the publishsetting file
this.createFile(publishSettingFileName, util.format('<?xml version="1.0" encoding="utf-8"?><PublishData><PublishProfile SchemaVersion="2.0" PublishMethod="AzureServiceManagementAPI"><Subscription ServiceManagementUrl="https://management.core.windows.net" Id="%s" Name="%s" ManagementCertificate="%s" /> </PublishProfile></PublishData>',subscriptionId, subscriptionName, certificate));
this.createFile(publishSettingFileName, util.format('<?xml version="1.0" encoding="utf-8"?><PublishData><PublishProfile SchemaVersion="2.0" PublishMethod="AzureServiceManagementAPI"><Subscription ServiceManagementUrl="%s" Id="%s" Name="%s" ManagementCertificate="%s" /> </PublishProfile></PublishData>',serviceManagementUrl, subscriptionId, subscriptionName, certificate));
}

private static createFile (filePath:string, data:string)
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCLI/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vsts-tasks-azurecli",
"version": "0.2.4",
"version": "0.2.6",
"description": "VSTS Azure CLI Task",
"main": "azureclitask.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCLI/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 5
"Patch": 6
},
"minimumAgentVersion": "1.95.0",
"instanceNameFormat": "Azure CLI $(scriptPath)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCLI/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 5
"Patch": 6
},
"minimumAgentVersion": "1.95.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
5 changes: 3 additions & 2 deletions Tests/L0/AzureCLI/azureLoginFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
"ENDPOINT_AUTH_AzureClassicFail": "{\"parameters\":{\"certificate\":\"cert\"},\"scheme\":\"Certificate\"}",
"ENDPOINT_DATA_AzureClassicFail_SUBSCRIPTIONNAME": "sName",
"ENDPOINT_DATA_AzureClassicFail_SUBSCRIPTIONID": "sId",
"ENDPOINT_URL_AzureClassicFail":"https://www.sampleServiceUrl.net/",
"ENDPOINT_AUTH_AzureRM": "{\"parameters\":{\"serviceprincipalid\":\"id\",\"serviceprincipalkey\":\"key\",\"tenantid\":\"tenant\"},\"scheme\":\"ServicePrincipal\"}",
"ENDPOINT_AUTH_AzureRMFail": "{\"parameters\":{\"serviceprincipalid\":\"idf\",\"serviceprincipalkey\":\"keyf\",\"tenantid\":\"tenantf\"},\"scheme\":\"ServicePrincipal\"}",
"ENDPOINT_DATA_AzureRM_SUBSCRIPTIONNAME": "sName",
"ENDPOINT_DATA_AzureRMFail_SUBSCRIPTIONNAME": "sName"
}
}
}
}
1 change: 1 addition & 0 deletions Tests/L0/AzureCLI/azureclitaskPass.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"ENDPOINT_AUTH_AzureClassic": "{\"parameters\":{\"certificate\":\"cert\"},\"scheme\":\"Certificate\"}",
"ENDPOINT_DATA_AzureClassic_SUBSCRIPTIONNAME": "sName",
"ENDPOINT_DATA_AzureClassic_SUBSCRIPTIONID": "sId",
"ENDPOINT_URL_AzureClassic":"https://www.sampleServiceUrl.net/",
"ENDPOINT_AUTH_AzureRM": "{\"parameters\":{\"serviceprincipalid\":\"id\",\"serviceprincipalkey\":\"key\",\"tenantid\":\"tenant\"},\"scheme\":\"ServicePrincipal\"}",
"ENDPOINT_DATA_AzureRM_SUBSCRIPTIONNAME": "sName"
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/L0/AzureCLI/scriptExecutionFailed.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"stdout":"bash execution failed",
"stderr": "bash stderr"
},
"scriptfail.bat arg1": {
"scriptfail.bat arg1": {
"code": 1,
"stdout":"cmd execution failed",
"stderr": "cmd stderr"
Expand Down Expand Up @@ -60,6 +60,7 @@
"ENDPOINT_AUTH_AzureClassic": "{\"parameters\":{\"certificate\":\"cert\"},\"scheme\":\"Certificate\"}",
"ENDPOINT_DATA_AzureClassic_SUBSCRIPTIONNAME": "sName",
"ENDPOINT_DATA_AzureClassic_SUBSCRIPTIONID": "sId",
"ENDPOINT_URL_AzureClassic":"https://www.sampleServiceUrl.net/",
"ENDPOINT_AUTH_AzureRM": "{\"parameters\":{\"serviceprincipalid\":\"id\",\"serviceprincipalkey\":\"key\",\"tenantid\":\"tenant\"},\"scheme\":\"ServicePrincipal\"}",
"ENDPOINT_DATA_AzureRM_SUBSCRIPTIONNAME": "sName"
}
Expand Down

0 comments on commit 8c902da

Please sign in to comment.