@@ -92,14 +92,10 @@ param (
9292 [Parameter ()]
9393 [switch ] $SuppressVsoCommands = ($null -eq $env: SYSTEM_TEAMPROJECTID ),
9494
95- # Default behavior is to use -UserAuth
95+ # Default behavior is to use logged in credentials
9696 [Parameter ()]
9797 [switch ] $ServicePrincipalAuth ,
9898
99- [Parameter ()]
100- [switch ] $FederatedAuth ,
101-
102-
10399 # Captures any arguments not declared here (no parameter errors)
104100 # This enables backwards compatibility with old script versions in
105101 # hotfix branches if and when the dynamic subscription configuration
@@ -110,19 +106,9 @@ param (
110106
111107. $PSScriptRoot / SubConfig- Helpers.ps1
112108
113- if ($FederatedAuth -and $ServicePrincipalAuth ) {
114- Write-Error " Only one of 'FederatedAuth' and 'ServicePrincipalAuth' can be set."
115- exit 1
116- }
117-
118- $UserAuth = $true
119- if ($ServicePrincipalAuth ) {
120- $UserAuth = $false
121- }
122-
123- if ($FederatedAuth ) {
124- # Clear secrets if FederatedAuth is set. This prevents secrets from being
125- # passed to pre- and post-scripts.
109+ if (! $ServicePrincipalAuth ) {
110+ # Clear secrets if not using Service Principal auth. This prevents secrets
111+ # from being passed to pre- and post-scripts.
126112 $PSBoundParameters [' TestApplicationSecret' ] = $TestApplicationSecret = ' '
127113 $PSBoundParameters [' ProvisionerApplicationSecret' ] = $ProvisionerApplicationSecret = ' '
128114}
@@ -299,7 +285,7 @@ function BuildDeploymentOutputs([string]$serviceName, [object]$azContext, [objec
299285 " AZURE_SERVICE_DIRECTORY" = $serviceName.ToUpperInvariant ();
300286 }
301287
302- if (! $FederatedAuth ) {
288+ if ($ServicePrincipalAuth ) {
303289 $deploymentOutputs [" ${serviceDirectoryPrefix} CLIENT_ID" ] = $TestApplicationId ;
304290 $deploymentOutputs [" ${serviceDirectoryPrefix} CLIENT_SECRET" ] = $TestApplicationSecret ;
305291 $deploymentOutputs [" ${serviceDirectoryPrefix} TENANT_ID" ] = $azContext.Tenant.Id ;
@@ -543,9 +529,8 @@ try {
543529 }
544530 }
545531
546- # If a provisioner service principal was provided (and not using Federated
547- # Auth), log into it to perform the pre- and post-scripts and deployments.
548- if ($ProvisionerApplicationId -and ! $FederatedAuth ) {
532+ # If a provisioner service principal was provided log into it to perform the pre- and post-scripts and deployments.
533+ if ($ProvisionerApplicationId -and $ServicePrincipalAuth ) {
549534 $null = Disable-AzContextAutosave - Scope Process
550535
551536 Log " Logging into service principal '$ProvisionerApplicationId '."
@@ -640,9 +625,9 @@ try {
640625 }
641626 }
642627
643- if (! $CI -and ! $FederatedAuth -and $UserAuth ) {
628+ if (! $CI -and ! $ServicePrincipalAuth ) {
644629 if ($TestApplicationId ) {
645- Write-Warning " The specified TestApplicationId '$TestApplicationId ' will be ignored when UserAuth is set."
630+ Write-Warning " The specified TestApplicationId '$TestApplicationId ' will be ignored when -ServicePrincipalAutth is not set."
646631 }
647632
648633 $userAccount = (Get-AzADUser - UserPrincipalName (Get-AzContext ).Account)
@@ -712,7 +697,7 @@ try {
712697 # Make sure pre- and post-scripts are passed formerly required arguments.
713698 $PSBoundParameters [' TestApplicationId' ] = $TestApplicationId
714699 $PSBoundParameters [' TestApplicationOid' ] = $TestApplicationOid
715- if (! $FederatedAuth ) {
700+ if ($ServicePrincipalAuth ) {
716701 $PSBoundParameters [' TestApplicationSecret' ] = $TestApplicationSecret
717702 }
718703
@@ -732,7 +717,7 @@ try {
732717 # considered a critical failure, as the test application may have subscription-level permissions and not require
733718 # the explicit grant.
734719 if (! $resourceGroupRoleAssigned ) {
735- $idSlug = if ($UserAuth ) { " User '$userAccountName ' ('$TestApplicationId ')" } else { " Test Application '$TestApplicationId '" };
720+ $idSlug = if (! $ServicePrincipalAuth ) { " User '$userAccountName ' ('$TestApplicationId ')" } else { " Test Application '$TestApplicationId '" };
736721 Log " Attempting to assign the 'Owner' role for '$ResourceGroupName ' to the $idSlug "
737722 $ownerAssignment = New-AzRoleAssignment `
738723 - RoleDefinitionName " Owner" `
@@ -762,7 +747,7 @@ try {
762747 if ($TenantId ) {
763748 $templateParameters.Add (' tenantId' , $TenantId )
764749 }
765- if ($TestApplicationSecret -and ! $FederatedAuth ) {
750+ if ($TestApplicationSecret -and $ServicePrincipalAuth ) {
766751 $templateParameters.Add (' testApplicationSecret' , $TestApplicationSecret )
767752 }
768753
@@ -1044,30 +1029,15 @@ The environment file will be named for the test resources template that it was
10441029generated for. For ARM templates, it will be test-resources.json.env. For
10451030Bicep templates, test-resources.bicep.env.
10461031
1047- . PARAMETER UserAuth
1048- Create the resource group and deploy the template using the signed in user's credentials.
1049- No service principal will be created or used.
1050-
1051- The environment file will be named for the test resources template that it was
1052- generated for. For ARM templates, it will be test-resources.json.env. For
1053- Bicep templates, test-resources.bicep.env.
1054-
10551032. PARAMETER SuppressVsoCommands
10561033By default, the -CI parameter will print out secrets to logs with Azure Pipelines log
10571034commands that cause them to be redacted. For CI environments that don't support this (like
10581035stress test clusters), this flag can be set to $false to avoid printing out these secrets to the logs.
10591036
10601037. PARAMETER ServicePrincipalAuth
1061- Use the signed in user's credentials to create a service principal for
1062- provisioning. This is useful for some local development scenarios.
1063-
1064- . PARAMETER FederatedAuth
1065- Use signed in user's credentials for provisioninig. No service principal will be
1066- created. This is used in CI where the execution context already has a signed in
1067- user.
1068-
1069- In cases where provisioner or test applications are specified, secrets for those
1070- apps will not be exported or made available to pre- or post- scripts.
1038+ Use the provisioner SP credentials to deploy, and pass the test SP credentials
1039+ to tests. If provisioner and test SP are not set, provision an SP with user
1040+ credentials and pass the new SP to tests.
10711041
10721042. EXAMPLE
10731043Connect-AzAccount -Subscription 'REPLACE_WITH_SUBSCRIPTION_ID'
0 commit comments