Skip to content

Commit

Permalink
Merge pull request #6 from miiitch/feature/AddAzureRMEndpointFull
Browse files Browse the repository at this point in the history
Add Service Principal parameters to the Add-AzureRMServiceEndpoint cmdlet
  • Loading branch information
DarqueWarrior authored May 19, 2017
2 parents 5b251c7 + f63b58d commit 0822c9f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
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

0 comments on commit 0822c9f

Please sign in to comment.