diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 654489794..7bf1955e1 100755 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -199,18 +199,6 @@ try { -serviceDirectoryName $serviceName ` -CI $CI - if ($wellKnownTMETenants.Contains($TenantId)) { - # Add a prefix to the resource group name to avoid flagging the usages of local auth - # See details at https://eng.ms/docs/products/onecert-certificates-key-vault-and-dsms/key-vault-dsms/certandsecretmngmt/credfreefaqs#how-can-i-disable-s360-reporting-when-testing-customer-facing-3p-features-that-depend-on-use-of-unsafe-local-auth - $ResourceGroupName = "SSS3PT_" + $ResourceGroupName - } - - if ($ResourceGroupName.Length -gt 90) { - # See limits at https://docs.microsoft.com/azure/architecture/best-practices/resource-naming - Write-Warning -Message "Resource group name '$ResourceGroupName' is too long. So pruning it to be the first 90 characters." - $ResourceGroupName = $ResourceGroupName.Substring(0, 90) - } - # Make sure pre- and post-scripts are passed formerly required arguments. $PSBoundParameters['BaseName'] = $BaseName @@ -304,6 +292,19 @@ try { } } + # This needs to happen after we set the TenantId but before we use the ResourceGroupName + if ($wellKnownTMETenants.Contains($TenantId)) { + # Add a prefix to the resource group name to avoid flagging the usages of local auth + # See details at https://eng.ms/docs/products/onecert-certificates-key-vault-and-dsms/key-vault-dsms/certandsecretmngmt/credfreefaqs#how-can-i-disable-s360-reporting-when-testing-customer-facing-3p-features-that-depend-on-use-of-unsafe-local-auth + $ResourceGroupName = "SSS3PT_" + $ResourceGroupName + } + + if ($ResourceGroupName.Length -gt 90) { + # See limits at https://docs.microsoft.com/azure/architecture/best-practices/resource-naming + Write-Warning -Message "Resource group name '$ResourceGroupName' is too long. So pruning it to be the first 90 characters." + $ResourceGroupName = $ResourceGroupName.Substring(0, 90) + } + # If a provisioner service principal was provided log into it to perform the pre- and post-scripts and deployments. if ($ProvisionerApplicationId -and $ServicePrincipalAuth) { $null = Disable-AzContextAutosave -Scope Process