Skip to content

Instantly share code, notes, and snippets.

@mattruma

mattruma/createKeyVaultSecret.bicep Secret

Last active Nov 22, 2020
Embed
What would you like to do?
Adventure with Bicep: Cosmos Connection Strings
param keyVaultName string
param secretName string
param secretValue string
resource keyVaultSecret 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = {
name: '${keyVaultName}/${secretName}'
properties: {
value: secretValue
}
}
output keyVaultSecretName string = keyVaultSecret.name
param keyVaultAccountName string
param cosmosDatabaseAccountName string
module cosmosKeyVaultSecretPrimaryConnectionString '../modules/moduleKeyVaultSecret.bicep' = {
name: 'cosmosKeyVaultSecretPrimaryConnectionString'
params: {
keyVaultName: keyVaultAccountName
secretName: '${cosmosDatabaseAccountName}-PrimaryConnectionString'
secretValue: listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', cosmosDatabaseAccountName), '2020-04-01').connectionStrings[0].connectionString
}
}
module cosmosKeyVaultSecretSecondaryConnectionString '../modules/moduleKeyVaultSecret.bicep' = {
name: 'cosmosKeyVaultSecretSecondaryConnectionString'
params: {
keyVaultName: keyVaultAccountName
secretName: '${cosmosDatabaseAccountName}-SecondaryConnectionString'
secretValue: listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', cosmosDatabaseAccountName), '2020-04-01').connectionStrings[1].connectionString
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment