@@ -75,18 +75,17 @@ param existingFabricCapacityName string = ''
7575
7676var useExistingEventHubNamespace = !empty (existingEventHubNamespaceId )
7777// ARM eagerly evaluates both ternary branches at validation time, causing split('', '/')[n]
78- // to throw index-out-of-bounds when the param is empty. Normalise to a structurally valid
79- // ARM resource ID using the nil GUID (00000000-...) as subscription — a GUID Azure never
80- // issues — so scope: resourceGroup(...) passes validation but can never target anything real.
81- // The module is still gated by if(useExistingEventHubNamespace) and never deploys unless
82- // a real existing namespace ID is provided.
78+ // to throw index-out-of-bounds when the param is empty. Provide a structurally valid
79+ // placeholder so the split is always safe. The nil GUID can never match a real subscription.
8380var _safeEventHubNamespaceId = empty (existingEventHubNamespaceId )
8481 ? '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/placeholder/providers/Microsoft.EventHub/namespaces/placeholder'
8582 : existingEventHubNamespaceId
8683// Extract name, subscription ID, and resource group from the resource ID.
87- var eventHubNamespaceNameFromId = last (split (_safeEventHubNamespaceId , '/' ))
88- var eventHubNamespaceSubscriptionId = split (_safeEventHubNamespaceId , '/' )[2 ]
89- var eventHubNamespaceResourceGroup = split (_safeEventHubNamespaceId , '/' )[4 ]
84+ // Supports cross-subscription/cross-resource-group deployments
85+ // (e.g. namespace in sub-123/rg-shared while deploying to sub-456/rg-demo).
86+ var eventHubNamespaceNameFromId = useExistingEventHubNamespace ? last (split (_safeEventHubNamespaceId , '/' )) : ''
87+ var eventHubNamespaceSubscriptionId = useExistingEventHubNamespace ? split (_safeEventHubNamespaceId , '/' )[2 ] : ''
88+ var eventHubNamespaceResourceGroup = useExistingEventHubNamespace ? split (_safeEventHubNamespaceId , '/' )[4 ] : ''
9089var useExistingFabricCapacity = !empty (existingFabricCapacityName )
9190
9291var solutionSuffix = toLower (trim (replace (
0 commit comments