Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 2592 #22612

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -651,7 +655,9 @@ try {
baseName = $BaseName
testApplicationId = $TestApplicationId
testApplicationOid = "$TestApplicationOid"
provisionerApplicationOid = "$provisionerApplicationOid"
}
if ($ProvisionerApplicationOid) {
$templateParameters["provisionerApplicationOid"] = "$ProvisionerApplicationOid"
}

if ($TenantId) {
Expand Down