3

I am learning about bicep and how to use to deploy azure resources. I have been working on key vault deployment as follow:

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 would like to do now, is create a GUID for each deployment in this format for example:

b402c7ed-0c50-4c07-91c4-e075694fdd30

I couldn't find any source to achieve this.

Can anyone please direct me on the right path.

Thank you very much for any help and for your patience with a beginner

Thomas
  • 24,234
  • 6
  • 81
  • 125
Nayden Van
  • 1,133
  • 1
  • 23
  • 70

1 Answers1

4

You can use the newGuid function, as per documentation:

Returns a value in the format of a globally unique identifier. This function can only be used in the default value for a parameter.

// parameter with default value
param deploymentId string = newGuid()
...
output deploymentId string = deploymentId

Thomas
  • 24,234
  • 6
  • 81
  • 125