-
Notifications
You must be signed in to change notification settings - Fork 526
Closed
Labels
Class: Resource Module 📦This is a resource moduleThis is a resource moduleType: AVM 🅰️ ✌️ Ⓜ️This is an AVM related issueThis is an AVM related issueType: Feature Request ➕New feature or requestNew feature or request
Description
Check for previous/existing GitHub issues
- I have checked for previous/existing GitHub issues
Issue Type?
Feature Request
Module Name
avm/res/event-hub/namespace
(Optional) Module Version
No response
Description
1. Problem
I tried to get connection string of event hub namespace by method like this:
module eventHubNamespace 'br/public:avm/res/event-hub/namespace:0.7.1' = {
name: 'eventHubNamespace'
params: {
name: '${abbrs.eventHubNamespaces}${resourceToken}'
location: location
roleAssignments: [
]
eventhubs: [
{
name: 'eventhubone'
}
]
}
}
module samples 'br/public:avm/res/app/container-app:0.8.0' = {
name: 'samples'
params: {
containers: [
{
env: union([
{
name: 'SPRING_CLOUD_AZURE_EVENTHUBS_CONNECTION_STRING'
listKeys('${eventHubNamespace.outputs.resourceId}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryConnectionString
}
],
}
]
}
}
It returns error like this:
Error BCP181: This expression is being used in an argument of the function "listKeys", which requires a value that can be calculated at the start of the deployment. Properties of eventHubNamespace which can be calculated at the start include "name".
2. Try to solve this issue
2.1. Use resourceId
I also tried this:
value: listKeys(concat(resourceId('Microsoft.EventHub/namespaces', eventHubNamespace.outputs.name), '/AuthorizationRules/RootManageSharedAccessKey'), '2024-01-01').primaryConnectionString
It returns error like this:
Error BCP181: This expression is being used in an argument of the function "listKeys", which requires a value that can be calculated at the start of the deployment. Properties of eventHubNamespace which can be calculated at the start include "name".
2.2. Use resourceId and ${abbrs.eventHubNamespaces}${resourceToken}
And tried this:
value: listKeys(concat(resourceId('Microsoft.EventHub/namespaces', '${abbrs.eventHubNamespaces}${resourceToken}'), '/AuthorizationRules/RootManageSharedAccessKey'), '2024-01-01').primaryConnectionString
It returns error like this:
Failed to perform 'action' on resource(s) of type 'namespaces/authorizationrules', because the parent resource '/subscriptions/471cca20-96cf-49ce-b242-4e67f0e14e19/resourceGroups/rg-azd-eh-dev-password-1/providers/Microsoft.EventHub/namespaces/evhns-5gz2gy5bznsvs' could not be found.
2.3. Add dependsOn
Tried this:
module samples 'br/public:avm/res/app/container-app:0.8.0' = {
name: 'samples'
params: {
containers: [
{
env: union([
{
name: 'SPRING_CLOUD_AZURE_EVENTHUBS_CONNECTION_STRING'
value: listKeys(concat(resourceId('Microsoft.EventHub/namespaces', '${abbrs.eventHubNamespaces}${resourceToken}'), '/AuthorizationRules/RootManageSharedAccessKey'), '2024-01-01').primaryConnectionString // Issue: https://github.com/Azure/bicep-registry-modules/issues/3638
}
],
}
]
}
dependsOn: [
eventHubNamespace
]
}
And failed with same error:
Failed to perform 'action' on resource(s) of type 'namespaces/authorizationrules', because the parent resource '/subscriptions/471cca20-96cf-49ce-b242-4e67f0e14e19/resourceGroups/rg-azd-eh-dev-password-2/providers/Microsoft.EventHub/namespaces/evhns-pmybghym7qjpc' could not be found.
Question / Feature request
My question is: How can I get connection when event hub namespace is created by br/public:avm/res/event-hub/namespace:0.7.1 ? May be we can add the connection-string in output?
(Optional) Correlation Id
No response
Metadata
Metadata
Assignees
Labels
Class: Resource Module 📦This is a resource moduleThis is a resource moduleType: AVM 🅰️ ✌️ Ⓜ️This is an AVM related issueThis is an AVM related issueType: Feature Request ➕New feature or requestNew feature or request
Type
Projects
Status
Done