Coder Perfect

Bicep Generate GUID


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: '${}/${keyVaultKeyPrefix}${tenantCode}'
  properties: {
    keySize: 2048
    kty: 'RSA'
    // storage key should only needs these operations
    keyOps: [

What I’d like to do now is generate a GUID for each deployment that looks like this:


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