From ec62101b37fe39609c1b9f5d993ba981f2217d08 Mon Sep 17 00:00:00 2001 From: Eric Sciple Date: Thu, 12 May 2016 12:11:16 -0400 Subject: [PATCH] Update AzureRM preference to rely on auth scheme rather than connection type. --- .../VstsAzureHelpers_/VstsAzureHelpers_.psm1 | 2 +- .../Initialize-Azure.PassesInputs.ps1 | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 index e8766a8cc634..db11a2b5c41b 100644 --- a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 +++ b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 @@ -34,7 +34,7 @@ function Initialize-Azure { # Determine which modules are preferred. $preferredModules = @( ) - if ($serviceNameInput -eq 'ConnectedServiceNameARM') { + if ($endpoint.Auth.Scheme -eq 'ServicePrincipal') { $preferredModules += 'AzureRM' } elseif ($endpoint.Auth.Scheme -eq 'UserNamePassword') { $preferredModules += 'Azure' diff --git a/Tests/L0/Common-VstsAzureHelpers_/Initialize-Azure.PassesInputs.ps1 b/Tests/L0/Common-VstsAzureHelpers_/Initialize-Azure.PassesInputs.ps1 index 2a94be47398f..9b85e7fb4980 100644 --- a/Tests/L0/Common-VstsAzureHelpers_/Initialize-Azure.PassesInputs.ps1 +++ b/Tests/L0/Common-VstsAzureHelpers_/Initialize-Azure.PassesInputs.ps1 @@ -5,6 +5,14 @@ param() . $PSScriptRoot/../../lib/Initialize-Test.ps1 Microsoft.PowerShell.Core\Import-Module $PSScriptRoot/../../../Tasks/AzurePowerShell/ps_modules/VstsAzureHelpers_ $variableSets = @( + @{ + ConnectedServiceNameSelector = 'ConnectedServiceName' + DeploymentEnvironmentName = $null + Endpoint = @{ Auth = @{ Scheme = 'ServicePrincipal' } } + StorageAccount = $null + ExpectedServiceNameInput = 'ConnectedServiceName' + ExpectedPreferredModule = ,'AzureRM' + } @{ ConnectedServiceNameSelector = 'ConnectedServiceName' DeploymentEnvironmentName = $null @@ -24,7 +32,7 @@ $variableSets = @( @{ ConnectedServiceNameSelector = 'ConnectedServiceName' DeploymentEnvironmentName = $null - Endpoint = 'Some endpoint' + Endpoint = @{ Auth = @{ Scheme = 'Certificate' } } StorageAccount = $null ExpectedServiceNameInput = 'ConnectedServiceName' ExpectedPreferredModule = ,'Azure' @@ -32,7 +40,7 @@ $variableSets = @( @{ ConnectedServiceNameSelector = 'ConnectedServiceName' DeploymentEnvironmentName = $null - Endpoint = 'Some endpoint' + Endpoint = @{ Auth = @{ Scheme = 'Certificate' } } StorageAccount = 'Some storage account' ExpectedServiceNameInput = 'ConnectedServiceName' ExpectedPreferredModule = ,'Azure' @@ -40,7 +48,7 @@ $variableSets = @( @{ ConnectedServiceNameSelector = 'ConnectedServiceNameARM' DeploymentEnvironmentName = $null - Endpoint = 'Some endpoint' + Endpoint = @{ Auth = @{ Scheme = 'ServicePrincipal' } } StorageAccount = $null ExpectedServiceNameInput = 'ConnectedServiceNameARM' ExpectedPreferredModule = ,'AzureRM' @@ -48,7 +56,7 @@ $variableSets = @( @{ ConnectedServiceNameSelector = 'ConnectedServiceNameARM' DeploymentEnvironmentName = $null - Endpoint = 'Some endpoint' + Endpoint = @{ Auth = @{ Scheme = 'ServicePrincipal' } } StorageAccount = 'Some storage account' ExpectedServiceNameInput = 'ConnectedServiceNameARM' ExpectedPreferredModule = ,'AzureRM'