diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 18127b3a714..f4f3be8de90 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -45,6 +45,10 @@ param ( [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] [string] $ProvisionerApplicationId, + [Parameter(ParameterSetName = 'Provisioner', Mandatory = $false)] + [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] + [string] $ProvisionerApplicationOid, + [Parameter(ParameterSetName = 'Provisioner', Mandatory = $true)] [string] $ProvisionerApplicationSecret, @@ -155,7 +159,7 @@ function NewServicePrincipalWrapper([string]$subscription, [string]$resourceGrou $appId = $servicePrincipal.AppId } else { Write-Verbose "Creating service principal credential via MS Graph API" - # In 7.1.0 the password credential issue was fixed (see https://github.com/Azure/azure-powershell/pull/16690) but the + # In 5.2.0 the password credential issue was fixed (see https://github.com/Azure/azure-powershell/pull/16690) but the # parameter set was changed making the above call fail due to a missing ServicePrincipalId parameter. $credential = Retry { $servicePrincipal | New-AzADSpCredential } $spPassword = ConvertTo-SecureString $credential.SecretText -AsPlainText -Force @@ -481,19 +485,19 @@ try { $context = Get-AzContext; # Make sure the provisioner OID is set so we can pass it through to the deployment. - $provisionerApplicationOid = if (!$ProvisionerApplicationId) { + if (!$ProvisionerApplicationId -and !$ProvisionerApplicationOid) { if ($context.Account.Type -eq 'User') { $user = Get-AzADUser -UserPrincipalName $context.Account.Id - $user.Id + $ProvisionerApplicationOid = $user.Id } elseif ($context.Account.Type -eq 'ServicePrincipal') { $sp = Get-AzADServicePrincipal -ApplicationId $context.Account.Id - $sp.Id + $ProvisionerApplicationOid = $sp.Id } else { Write-Warning "Getting the OID for provisioner type '$($context.Account.Type)' is not supported and will not be passed to deployments (seldom required)." } - } else { + } elseif (!$ProvisionerApplicationOid) { $sp = Get-AzADServicePrincipal -ApplicationId $ProvisionerApplicationId - $sp.Id + $ProvisionerApplicationOid = $sp.Id } # If the ServiceDirectory has multiple segments use the last directory name @@ -651,7 +655,9 @@ try { baseName = $BaseName testApplicationId = $TestApplicationId testApplicationOid = "$TestApplicationOid" - provisionerApplicationOid = "$provisionerApplicationOid" + } + if ($ProvisionerApplicationOid) { + $templateParameters["provisionerApplicationOid"] = "$ProvisionerApplicationOid" } if ($TenantId) {