Problem
Bicep is something I’m learning about and how to utilize it to deploy Azure resources. I’ve been working on the following key vault deployment:
resource keyVault 'Microsoft.KeyVault/vaults@2021-06-01-preview' existing = {
name: keyVaultName
}
// Create key vault keys
resource keyVaultKeys 'Microsoft.KeyVault/vaults/keys@2021-06-01-preview' = [for tenantCode in tenantCodes: {
name: '${keyVault.name}/${keyVaultKeyPrefix}${tenantCode}'
properties: {
keySize: 2048
kty: 'RSA'
// storage key should only needs these operations
keyOps: [
'unwrapKey'
'wrapKey'
]
}
}]
What I’d like to do now is generate a GUID for each deployment that looks like this:
b402c7ed-0c50-4c07-91c4-e075694fdd30
I couldn’t locate any information on how to do this.
Could someone please point me in the correct direction?
Thank you very much for your assistance and patience with a novice.
Asked by Nayden Van
Solution #1
According to the documentation, you can use the newGuid function:
// parameter with default value
param deploymentId string = newGuid()
...
output deploymentId string = deploymentId
Answered by Thomas
Post is based on https://stackoverflow.com/questions/69678760/bicep-generate-guid