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

Add Service Principal parameters to the Add-AzureRMServiceEndpoint cmdlet #6

Merged
merged 3 commits into from
May 19, 2017
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ To get started you can visit this blog [PowerShell I would like you to meet TFS
The cases of every file is very important. This module is to be used on Windows, Linux and OSx so case is important. If the casing does not match Linux and OSx might fail.

# Release Notes
## 0.1.20
Merge [Pull Request](https://github.com/DarqueWarrior/team/pull/6)from [Michel Perfetti](https://github.com/miiitch) which included the following:

- Added serviceEndpoint parameters to Add-AzureRMServiceEndpoint cmdlet: if the serviceEndPoint parameters are not specified, the Automatic mode is used
- The _trackProgress function was changed too to reflect the return code of the api (https://www.visualstudio.com/en-us/docs/integrate/api/endpoints/endpoints)
- The URL in the payload changed to https://management.azure.com

## 0.1.19
Removed test folder from module

Expand Down
2 changes: 1 addition & 1 deletion Team.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
RootModule = ''

# Version number of this module.
ModuleVersion = '0.1.19'
ModuleVersion = '0.1.20'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
25 changes: 18 additions & 7 deletions src/serviceendpoints.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function _trackProgress {
$url = _buildURL -projectName $projectName -id $resp.id

# Track status
while ($status -ne 'Failed' -and $status -ne 'Ready') {
$status = (_checkStatus $url).operationStatus.state
while ($status -ne '$true') {
$status = (_checkStatus $url).isReady

# oscillate back a forth to show progress
$i += $x
Expand Down Expand Up @@ -142,7 +142,9 @@ function Add-AzureRMServiceEndpoint {
[string] $subscriptionId,
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string] $subscriptionTenantId,
[string] $endpointName
[string] $endpointName,
[string] $servicePrincipalId,
[string] $servicePrincipalKey
)

DynamicParam {
Expand All @@ -160,23 +162,32 @@ function Add-AzureRMServiceEndpoint {
$endpointName = $displayName
}

if (-not $servicePrincipalId) {
$creationMode = "Automatic"
$servicePrincipalId=""
$servicePrincipalKey=""
}
else {
$creationMode = "Manual"
}

$obj = @{
authorization=@{
parameters=@{
serviceprincipalid='';
serviceprincipalkey='';
serviceprincipalid=$servicePrincipalId;
serviceprincipalkey=$servicePrincipalKey;
tenantid=$subscriptionTenantId
};
scheme='ServicePrincipal'
};
data=@{
subscriptionId=$subscriptionId;
subscriptionName=$displayName;
creationMode='Automatic'
creationMode=$creationMode
};
name=$endpointName;
type='azurerm';
url='https://management.core.windows.net/'
url='https://management.azure.com/'
}

$body = $obj | ConvertTo-Json
Expand Down
6 changes: 5 additions & 1 deletion test/serviceendpoints.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ InModuleScope serviceendpoints {
# This $i is in the module. Because we use InModuleScope
# we can see it
if ($i -gt 9) {
return @{operationStatus=@{state='Ready'}}
return @{
isReady=$true
operationStatus=@{state='Ready'}
}
}

return @{
isReady=$false
createdBy=@{}
authorization=@{}
data=@{}
Expand Down