Skip to content

Commit 5098f67

Browse files
Set the resource group prefix after we get the tenantId (#2526)
Given we are using the tenantId to determine to add the prefix or not we need to make sure we have it set before we check it. For the pipelines it is set at the script calling time so it was working there but for some local scenarios it is not set yet, so we need to do it a little later in the script. Co-authored-by: Wes Haggard <[email protected]>
1 parent 747a7e9 commit 5098f67

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,6 @@ try {
199199
-serviceDirectoryName $serviceName `
200200
-CI $CI
201201

202-
if ($wellKnownTMETenants.Contains($TenantId)) {
203-
# Add a prefix to the resource group name to avoid flagging the usages of local auth
204-
# 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
205-
$ResourceGroupName = "SSS3PT_" + $ResourceGroupName
206-
}
207-
208-
if ($ResourceGroupName.Length -gt 90) {
209-
# See limits at https://docs.microsoft.com/azure/architecture/best-practices/resource-naming
210-
Write-Warning -Message "Resource group name '$ResourceGroupName' is too long. So pruning it to be the first 90 characters."
211-
$ResourceGroupName = $ResourceGroupName.Substring(0, 90)
212-
}
213-
214202
# Make sure pre- and post-scripts are passed formerly required arguments.
215203
$PSBoundParameters['BaseName'] = $BaseName
216204

@@ -304,6 +292,19 @@ try {
304292
}
305293
}
306294

295+
# This needs to happen after we set the TenantId but before we use the ResourceGroupName
296+
if ($wellKnownTMETenants.Contains($TenantId)) {
297+
# Add a prefix to the resource group name to avoid flagging the usages of local auth
298+
# 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
299+
$ResourceGroupName = "SSS3PT_" + $ResourceGroupName
300+
}
301+
302+
if ($ResourceGroupName.Length -gt 90) {
303+
# See limits at https://docs.microsoft.com/azure/architecture/best-practices/resource-naming
304+
Write-Warning -Message "Resource group name '$ResourceGroupName' is too long. So pruning it to be the first 90 characters."
305+
$ResourceGroupName = $ResourceGroupName.Substring(0, 90)
306+
}
307+
307308
# If a provisioner service principal was provided log into it to perform the pre- and post-scripts and deployments.
308309
if ($ProvisionerApplicationId -and $ServicePrincipalAuth) {
309310
$null = Disable-AzContextAutosave -Scope Process

0 commit comments

Comments
 (0)