Skip to content

Commit a3c0cd5

Browse files
committed
Fix: Filter out empty FQDNs for Traffic Manager endpoints in Bicep, improve deployment robustness
1 parent af34ff9 commit a3c0cd5

File tree

6 files changed

+446
-12
lines changed

6 files changed

+446
-12
lines changed

AzureArchitecture/main.bicep

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// Filter out regional endpoints with empty FQDNs for Traffic Manager
2+
var filteredRegionalEndpoints = [
3+
for (region, index) in regions: {
4+
fqdn: regionalLayers[index].outputs.regionalEndpointFqdn
5+
location: region.regionName
6+
}
7+
if !empty(regionalLayers[index].outputs.regionalEndpointFqdn)
8+
]
19

210
// Azure Stamps Pattern - Main Orchestration Template
311
//
@@ -354,11 +362,16 @@ module globalLayer './globalLayer.bicep' = {
354362
enableGlobalCosmos: !isSmoke
355363
// Pass APIM gateway URL for Front Door configuration
356364
apimGatewayUrl: geodesLayer.outputs.apimGatewayUrl
357-
// Pass regional Application Gateway endpoints for Traffic Manager
365+
// Pass regional Application Gateway endpoints for Traffic Manager, filtering out empty FQDNs
358366
regionalEndpoints: [for (region, index) in regions: {
359367
fqdn: regionalLayers[index].outputs.regionalEndpointFqdn
360368
location: region.regionName
361-
}]
369+
} if !empty(regionalLayers[index].outputs.regionalEndpointFqdn)]
370+
// Filter out regional endpoints with empty FQDNs for Traffic Manager
371+
var filteredRegionalEndpoints = [for (region, index) in regions: {
372+
fqdn: regionalLayers[index].outputs.regionalEndpointFqdn
373+
location: region.regionName
374+
} if (!empty(regionalLayers[index].outputs.regionalEndpointFqdn))]
362375
}
363376
dependsOn: [
364377
geodesLayer

AzureArchitecture/regionalLayer.bicep

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ resource publicIp 'Microsoft.Network/publicIPAddresses@2022-05-01' existing = {
323323
output regionalEndpointIpAddress string = publicIp.properties.ipAddress
324324

325325
// Output the regional public IP FQDN for use in Front Door origins and Traffic Manager endpoints
326-
output regionalEndpointFqdn string = publicIp.properties.dnsSettings.fqdn
326+
// Output the regional public IP FQDN for use in Front Door origins and Traffic Manager endpoints
327+
// If dnsSettings is missing, output an empty string
328+
output regionalEndpointFqdn string = contains(publicIp.properties, 'dnsSettings') && contains(publicIp.properties.dnsSettings, 'fqdn') ? publicIp.properties.dnsSettings.fqdn : ''
327329

328330
// Output the Automation Account resource ID for integration or runbook assignment
329331
output automationAccountId string = enableAutomation ? automationAccount.id : ''

docs/TWO_STEP_DEPLOYMENT_GUIDE.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ This guide outlines the recommended two-step process for deploying the Stamps Pa
77
## Step 1: Deploy Core Infrastructure
88

99
1. **Automated Step 1: Deploy and Extract Outputs**
10-
- Run the `single-sub-deployment-step1.ps1` PowerShell script located in the `AzureArchitecture` folder to deploy `AzureArchitecture/main.bicep` and automatically extract the outputs needed for the management portal deployment.
10+
- Run the `single-sub-deployment-step1.ps1` PowerShell script from the `scripts` folder to deploy `AzureArchitecture/main.bicep` and automatically extract the outputs needed for the management portal deployment.
1111
- This script provisions all resource groups, core assets, and the management portal resource group, then writes the required outputs to `management-portal.parameters.json`.
12-
- Example usage:
13-
```pwsh
14-
cd AzureArchitecture
15-
pwsh ./single-sub-deployment-step1.ps1
16-
```
12+
- Example usage:
13+
```pwsh
14+
pwsh ./scripts/single-sub-deployment-step1.ps1
15+
```
1716
1817
- The script will:
1918
- Deploy the Bicep template using `main.parameters.json`.

management-portal/src/Portal/Services/AzureInfrastructureService.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,26 @@ public static ResourceGroupType Classify(string rgName)
3232
{
3333
if (string.IsNullOrWhiteSpace(rgName)) return ResourceGroupType.Other;
3434
var name = rgName.ToLowerInvariant();
35-
if (System.Text.RegularExpressions.Regex.IsMatch(name, @"^rg-.*cell.*", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
35+
36+
// Specific stamps pattern filtering rules
37+
// CELL RGs = only show RGs that contain "stamps-cell" in name
38+
if (name.Contains("stamps-cell"))
39+
{
3640
return ResourceGroupType.Cell;
37-
if (System.Text.RegularExpressions.Regex.IsMatch(name, @"^rg-.*region.*", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
41+
}
42+
43+
// Regional RGs = only show RGs that contain "stamps-region" in name
44+
if (name.Contains("stamps-region"))
45+
{
3846
return ResourceGroupType.Regional;
39-
if (System.Text.RegularExpressions.Regex.IsMatch(name, @"^rg-.*global.*", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
47+
}
48+
49+
// Global RGs = only show RGs that contain "stamps-management" or "stamps-global" in name
50+
if (name.Contains("stamps-management") || name.Contains("stamps-global"))
51+
{
4052
return ResourceGroupType.Global;
53+
}
54+
4155
return ResourceGroupType.Other;
4256
}
4357
}

0 commit comments

Comments
 (0)