Looping to create Storage Accounts, blob service and containers #18917
JonnyManc
started this conversation in
Authoring Help
Replies: 1 comment 1 reply
-
|
The simplest option is to create a module to deploy a set of containers, and loop over it: module containers 'blobContainers.bicep' = [for (sa,i) in myStorageAccounts: {
params: {
storageAccountName: sa.name
containers: blobs
}
}]The other option would be to simulate a multi-dimensional array using modulo, but that gets hard to wrap your head around - e.g. something like resource myBlob 'Microsoft.Storage/storageAccounts/blobServices/containers@2025-06-01' = [for i in length(myStorageAccounts) * length(myBlobs): {
// indexes if both lengths are 3 will be: 0, 0, 0, 1, 1, 1, 2, 2, 2
parent: myBlobService[i / length(myStorageAccounts)]
// indexes if both lengths are 3 will be: 0, 1, 2, 0, 1, 2, 0, 1, 2
name: blobs[i % length(myStorageAccounts)]
...
}] |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I have a requirement to deploy multiple storage account with the same Blob containers attached.
I am aware that currently directly referencing a looping resource is not allowed....and I have tried using an indexer but it just isnt quite right:
Its the creation of the blobs where the issue is.
I cant nest the blob service (loop issue)
I cant nest the blob loop in the blob service (loop issue)
I cant reference the resources directly
I've got a temp workaround as its only 1 of everything in dev, but test and prod need multiple SA and blobs.....
Thanks
Beta Was this translation helpful? Give feedback.
All reactions