I'm deploying a Key Vault via bicep file with some standard rules, then after the initial configuration of some other resources I want to harden that Key Vault with advanced properties. For instance, I deploy the Key Vault with this bicep file:
// keyVault_1.bicep
resource stdKeyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
name: 'kv-test-01'
location: resourceGroup().location
properties: {
...
}
}
Then I apply this second template (in incremental mode):
// keyVault_2.bicep
resource stdKeyVault 'Microsoft.KeyVault/vaults@2023-07-01' existing = {
name: 'kv-test-01'
}
resource secKeyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
name: 'kv-test-01'
location: resourceGroup().location
// join the current properties with the new property to preserve them
properties: union(stdKeyVault.properties, {
publicNetworkAccess: 'Disabled'
}
}
Would there be any other way to do this easily by extending the first bicep file instead of using two different standalone deployments?
These questions are similar but I can't see a definitive answer on this topic.