Error BCP109: The type "Microsoft.KeyVault/vaults/secrets" does not contain function "getSecret"

Brass Contributor

Hi, I am trying to pass the secret value as a secure parameter to a Bicep module, but I am getting the error: Error BCP109: The type "Microsoft.KeyVault/vaults/secrets" does not contain function "getSecret".

Code in main. Bicep file

resource myVaultSecret 'Microsoft.KeyVault/vaults/secrets@2023-02-01' existing = {

  name: 'myVault/mySecret'
}
....
module sqlModule 'sqlserver-module.bicep' = if (databaseService == 'sql') {
  name: 'sqlDeployment'
  params: {
    administratorLogin: administratorLogin
    administratorLoginPassword: myVaultSecret.getSecret('mySecret')
    location: location
    resourceGroup: resourceGroup
    serverName: serverName
    servicePlanSku: servicePlanSku
    sqlDBName: databaseName
    subcription: subscription
    tags: tags
    workloadEnv: workloadEnv
  }
}
#end main.bicep
 
code sqlserver-module.bicep file
@description('The administrator password for the SQL server.')
@secure()
param administratorLoginPassword string
 
 
Any help will be appreciated !!
Thanks
1 Reply
Perhaps I'm wrong, but I do not publicly see an API version 2023-02-01 for the Microsoft.KeyVault resource type, https://learn.microsoft.com/en-us/azure/templates/microsoft.keyvault/allversions. Regardless, in my case, this example worked for me https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-resource#getsec.... HTH.