Only fetch provision application oid via API if not supplied (#19961)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2022-01-21 12:02:15 -08:00 коммит произвёл GitHub
Родитель d9fe264832
Коммит fe007541ba
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -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) {