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 1175 #908

Merged
merged 1 commit into from
Nov 6, 2020
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
23 changes: 16 additions & 7 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ $UserName = if ($env:USER) { $env:USER } else { "${env:USERNAME}" }
if (!$BaseName) {
$BaseName = "$UserName$ServiceDirectory"

# Make sure pre- and post-scripts are passed formerly required arguments.
$PSBoundParameters['BaseName'] = $BaseName

Log "BaseName was not set. Using default base name: '$BaseName'"
}

Expand All @@ -167,8 +170,7 @@ if (!$Location) {
Write-Verbose "Location was not set. Using default location for environment: '$Location'"
}

# If no test application ID is specified during an interactive session, create a new service principal.
if (!$CI -and !$TestApplicationId) {
if (!$CI) {

# Make sure the user is logged in to create a service principal.
$context = Get-AzContext;
Expand All @@ -177,13 +179,20 @@ if (!$CI -and !$TestApplicationId) {
$context = (Connect-AzAccount -Subscription $defaultSubscription).Context
}

Log "TestApplicationId was not specified; creating a new service principal"
$servicePrincipal = New-AzADServicePrincipal -Role Owner
# If no test application ID is specified during an interactive session, create a new service principal.
if (!$TestApplicationId) {
Log "TestApplicationId was not specified; creating a new service principal"
$servicePrincipal = New-AzADServicePrincipal -Role Owner

$TestApplicationId = $servicePrincipal.ApplicationId
$TestApplicationSecret = (ConvertFrom-SecureString $servicePrincipal.Secret -AsPlainText);

$TestApplicationId = $servicePrincipal.ApplicationId
$TestApplicationSecret = (ConvertFrom-SecureString $servicePrincipal.Secret -AsPlainText);
# Make sure pre- and post-scripts are passed formerly required arguments.
$PSBoundParameters['TestApplicationId'] = $TestApplicationId
$PSBoundParameters['TestApplicationSecret'] = $TestApplicationSecret

Log "Created service principal '$TestApplicationId'"
Log "Created service principal '$TestApplicationId'"
}

if (!$ProvisionerApplicationId) {
$ProvisionerApplicationId = $TestApplicationId
Expand Down