I have got a module that creates managed identities within bicep, I designed it as a module which accepts an array as parameter so that I can pass an array of managed identities that I want created and it can be created at once, the issue here is that I need the ID's of the created user managed identity, I was wondering how I can retrieve the ID's and use it elsewhere.
one thing that springs to mind is declaring an array to store the ID's but that doesnt appear to work when I tested it, I am doing this incorrectly.
param managedIdentities array
param location string
param tagging object
param managed_identity_properties object
resource create_managed_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = [ for name in managedIdentities: {
name: name
location: location
tags: tagging.tags
} ]
// output managedIdentityIds array = [for identity in managedIdentities: identity.id]
output managedIdentityIds array = [resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', name) for name in managedIdentities]
How can I reference the value of the ID in other modules ? Ideally I would like to reference it by providing the managed instance, the array that I am sending to the module looks like this
"mi_resources": [
"mi-01",
"mi-02",
"mi-03",
"mi-04"
]
Use below code to achieve your requirement.
Output: