Skip to content

Commit 12d5186

Browse files
Revert "fix: bicep-fix- guard EventHub namespace ID split against ARM eager-evaluation"
This reverts commit 6364902.
1 parent 655314a commit 12d5186

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

infra/main.bicep

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,13 @@ param existingFabricCapacityName string = ''
7474
// ============================================================================
7575

7676
var useExistingEventHubNamespace = !empty(existingEventHubNamespaceId)
77-
// ARM eagerly evaluates both ternary branches at validation time, causing split('', '/')[n]
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.
80-
var _safeEventHubNamespaceId = empty(existingEventHubNamespaceId)
81-
? '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/placeholder/providers/Microsoft.EventHub/namespaces/placeholder'
82-
: existingEventHubNamespaceId
83-
// Extract name, subscription ID, and resource group from the resource ID.
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] : ''
77+
// Extract namespace name from resource ID if using existing, otherwise generate new name
78+
var eventHubNamespaceNameFromId = useExistingEventHubNamespace ? last(split(existingEventHubNamespaceId, '/')) : ''
79+
// Parse subscription ID and resource group from the namespace resource ID
80+
// This enables cross-subscription and cross-resource-group deployments
81+
// Example: namespace in sub-123/rg-shared while deploying to sub-456/rg-demo
82+
var eventHubNamespaceSubscriptionId = useExistingEventHubNamespace ? split(existingEventHubNamespaceId, '/')[2] : ''
83+
var eventHubNamespaceResourceGroup = useExistingEventHubNamespace ? split(existingEventHubNamespaceId, '/')[4] : ''
8984
var useExistingFabricCapacity = !empty(existingFabricCapacityName)
9085

9186
var solutionSuffix = toLower(trim(replace(

0 commit comments

Comments
 (0)