@@ -73,16 +73,16 @@ param existingFabricCapacityName string = ''
7373// This follows best practices for Event Hub usage.
7474// ============================================================================
7575
76+ var useExistingEventHubNamespace = !empty (existingEventHubNamespaceId )
7677// ARM eagerly evaluates both ternary branches at validation time, causing split('', '/')[n]
77- // to throw index-out-of-bounds when the param is empty. startsWith also handles unsubstituted
78- // '${ENV_VAR}' literals passed verbatim by az deployment validate (unlike azd which substitutes).
79- // The nil GUID placeholder is structurally valid for ARM but can never target a real resource .
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.
8081// The module is still gated by if(useExistingEventHubNamespace) and never deploys unless
8182// a real existing namespace ID is provided.
82- var useExistingEventHubNamespace = startsWith (existingEventHubNamespaceId , '/subscriptions/' )
83- var _safeEventHubNamespaceId = useExistingEventHubNamespace
84- ? existingEventHubNamespaceId
85- : '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/placeholder/providers/Microsoft.EventHub/namespaces/placeholder'
83+ var _safeEventHubNamespaceId = empty (existingEventHubNamespaceId )
84+ ? '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/placeholder/providers/Microsoft.EventHub/namespaces/placeholder'
85+ : existingEventHubNamespaceId
8686// Extract name, subscription ID, and resource group from the resource ID.
8787var eventHubNamespaceNameFromId = last (split (_safeEventHubNamespaceId , '/' ))
8888var eventHubNamespaceSubscriptionId = split (_safeEventHubNamespaceId , '/' )[2 ]
0 commit comments