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

Support for MSI #24

Merged
merged 7 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions Marketplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Usually this task is ran directly after the 'Azure Resource Group Deployment' ta

## Release notes

### Version 5.1 - 03-03-2019

- Deprecation warning for the PowerShell based version
- Support for MSI based agents

### Version 5.0 - 25-12-2018

- Rewrite to Node to enable Linux based agents
Expand Down
2 changes: 1 addition & 1 deletion arm-outputs/arm-outputsV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 4,
"Minor": 0,
"Patch": 3
"Patch": 5
},
"demands": [
"azureps"
Expand Down
6 changes: 3 additions & 3 deletions arm-outputs/arm-outputsV2/ArmOutputParams.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FailBehaviour } from "./FailBehaviour";
import * as msrestAzure from 'ms-rest-azure';
import { FailBehaviour } from "./FailBehaviour";
import { ServiceClientCredentials } from "ms-rest";

export class ArmOutputParams {
public tokenCredentials: msrestAzure.ApplicationTokenCredentials;
public tokenCredentials: ServiceClientCredentials;
public subscriptionId: string;
public resourceGroupName: string;
public prefix: string;
Expand Down
14 changes: 12 additions & 2 deletions arm-outputs/arm-outputsV2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ArmOutputParams } from './ArmOutputParams';
import { FailBehaviour } from './FailBehaviour';
import { _checkPath } from 'azure-pipelines-task-lib/internal';
import appInsights from "./logger"
import { ServiceClientCredentials } from 'ms-rest';

export class AzureDevOpsArmOutputsTaskHost {

Expand All @@ -15,7 +16,8 @@ export class AzureDevOpsArmOutputsTaskHost {
try {
let connectedServiceNameARM: string = tl.getInput("ConnectedServiceNameARM");
var endpointAuth = tl.getEndpointAuthorization(connectedServiceNameARM, true);
var credentials = this.getCredentials(endpointAuth);
var authScheme = tl.getEndpointAuthorizationScheme(connectedServiceNameARM, true);
var credentials = this.getCredentials(endpointAuth, authScheme);
var subscriptionId = tl.getEndpointDataParameter(connectedServiceNameARM, "SubscriptionId", true);

var resourceGroupName = tl.getInput("resourceGroupName", true);
Expand Down Expand Up @@ -73,10 +75,18 @@ export class AzureDevOpsArmOutputsTaskHost {
}
}

private getCredentials = (endpointAuthorization: tl.EndpointAuthorization): msrestAzure.ApplicationTokenCredentials => {
private getCredentials = (endpointAuthorization: tl.EndpointAuthorization, authScheme: string): ServiceClientCredentials => {
if (authScheme == "ManagedServiceIdentity") {
console.log("Logging in using MSIVmTokenCredentials");
return new msrestAzure.MSIVmTokenCredentials();
}

console.log(`Logging in using ApplicationTokenCredentials, authScheme is '${authScheme}'`);

var servicePrincipalId: string = endpointAuthorization.parameters["serviceprincipalid"];
var servicePrincipalKey: string = endpointAuthorization.parameters["serviceprincipalkey"];
var tenantId: string = endpointAuthorization.parameters["tenantid"];

var credentials = new msrestAzure.ApplicationTokenCredentials(servicePrincipalId, tenantId, servicePrincipalKey);

return credentials;
Expand Down
4 changes: 2 additions & 2 deletions arm-outputs/arm-outputsV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 5,
"Minor": 0,
"Patch": 20
"Patch": 21
},
"releaseNotes": "Complete rewrite from PowerShell to Node to enable Linux based agents",
"demands": [],
Expand Down Expand Up @@ -80,7 +80,7 @@
"type": "string",
"label": "Filter deployment name",
"required": false,
"helpMarkDown": "Optional string to filter deployments by. This can be useful if you have concurrent deployments to the same resource group. Deployment names in Azure Pipelines are the name of the JSON file plus the date and time, so a file `CreateKeyVault.json` could have a deployment name of `CreateKeyVault-20180025-151538-0688`. In this case, if you want to filter to deployments of this file enter `CreateKeyVault` as the filter."
"helpMarkDown": "Optional string to filter deployments by. This can be useful if you have concurrent deployments to the same resource group. Deployment names in Azure Pipelines are the name of the JSON file plus the date and time, so a file `CreateKeyVault.json` could have a deployment name of `CreateKeyVault-20180025-151538-0688`. In this case, if you want to filter to deployments of this file enter `CreateKeyVault` as the filter.<br/><br/>This uses [micromatch](https://github.com/micromatch/micromatch) under the hood (ignoring case) so us wildcards like *"
}
],
"dataSourceBindings": [
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "arm-outputs",
"name": "ARM Outputs",
"version": "5.1.4",
"version": "5.1.7",
"publisher": "keesschollaart",
"public": true,
"helpMarkDown": "[More Information](https://github.com/keesschollaart81/vsts-arm-outputs)",
Expand Down