@@ -45,6 +45,10 @@ param (
4545 [ValidatePattern (' ^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$' )]
4646 [string ] $ProvisionerApplicationId ,
4747
48+ [Parameter (ParameterSetName = ' Provisioner' , Mandatory = $false )]
49+ [ValidatePattern (' ^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$' )]
50+ [string ] $ProvisionerApplicationOid ,
51+
4852 [Parameter (ParameterSetName = ' Provisioner' , Mandatory = $true )]
4953 [string ] $ProvisionerApplicationSecret ,
5054
@@ -155,7 +159,7 @@ function NewServicePrincipalWrapper([string]$subscription, [string]$resourceGrou
155159 $appId = $servicePrincipal.AppId
156160 } else {
157161 Write-Verbose " Creating service principal credential via MS Graph API"
158- # In 7.1 .0 the password credential issue was fixed (see https://github.com/Azure/azure-powershell/pull/16690) but the
162+ # In 5.2 .0 the password credential issue was fixed (see https://github.com/Azure/azure-powershell/pull/16690) but the
159163 # parameter set was changed making the above call fail due to a missing ServicePrincipalId parameter.
160164 $credential = Retry { $servicePrincipal | New-AzADSpCredential }
161165 $spPassword = ConvertTo-SecureString $credential.SecretText - AsPlainText - Force
@@ -481,19 +485,19 @@ try {
481485 $context = Get-AzContext ;
482486
483487 # Make sure the provisioner OID is set so we can pass it through to the deployment.
484- $provisionerApplicationOid = if (! $ProvisionerApplicationId ) {
488+ if (! $ProvisionerApplicationId -and ! $ProvisionerApplicationOid ) {
485489 if ($context.Account.Type -eq ' User' ) {
486490 $user = Get-AzADUser - UserPrincipalName $context.Account.Id
487- $user.Id
491+ $ProvisionerApplicationOid = $ user.Id
488492 } elseif ($context.Account.Type -eq ' ServicePrincipal' ) {
489493 $sp = Get-AzADServicePrincipal - ApplicationId $context.Account.Id
490- $sp.Id
494+ $ProvisionerApplicationOid = $ sp.Id
491495 } else {
492496 Write-Warning " Getting the OID for provisioner type '$ ( $context.Account.Type ) ' is not supported and will not be passed to deployments (seldom required)."
493497 }
494- } else {
498+ } elseif ( ! $ProvisionerApplicationOid ) {
495499 $sp = Get-AzADServicePrincipal - ApplicationId $ProvisionerApplicationId
496- $sp.Id
500+ $ProvisionerApplicationOid = $ sp.Id
497501 }
498502
499503 # If the ServiceDirectory has multiple segments use the last directory name
@@ -651,7 +655,9 @@ try {
651655 baseName = $BaseName
652656 testApplicationId = $TestApplicationId
653657 testApplicationOid = " $TestApplicationOid "
654- provisionerApplicationOid = " $provisionerApplicationOid "
658+ }
659+ if ($ProvisionerApplicationOid ) {
660+ $templateParameters [" provisionerApplicationOid" ] = " $ProvisionerApplicationOid "
655661 }
656662
657663 if ($TenantId ) {
0 commit comments