How would you configure your Bicep code for the creation of a storage with advanced threat protection? #1504
-
Hello, First, thank you very much for your work on this project. I would like to know how you would configure your Bicep code to generate an ARM template that looks like the following one: https://github.com/Azure/azure-quickstart-templates/blob/master/201-storage-advanced-threat-protection-create/azuredeploy.json I tried to use modules, but I was not able to get it 100% right when generating the ARM template from the Bicep code. Thank you in advance for your advice. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Have you tried using the Here's the code it generated: param storageAccountName string {
metadata: {
description: 'The name must be unique across all existing storage account names in Azure. It must be 3 to 24 characters long, and can contain only lowercase letters and numbers.'
}
default: 'atpstorage${uniqueString(resourceGroup().id)}'
}
param location string {
metadata: {
description: 'Storage account location, default is same as resource group location.'
}
default: resourceGroup().location
}
param storageAccountKind string {
allowed: [
'StorageV2'
'Storage'
]
metadata: {
description: 'Storage account type, for more info see \'https://docs.microsoft.com/en-us/azure/storage/common/storage-account-overview\'.'
}
default: 'StorageV2'
}
param storageAccountReplication string {
allowed: [
'Standard_LRS'
'Standard_GRS'
'Standard_ZRS'
'Premium_LRS'
]
metadata: {
description: 'Storage account replication, for more info see \'https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy\'.'
}
default: 'Standard_LRS'
}
param advancedThreatProtectionEnabled bool {
metadata: {
description: 'Enable or disable Advanced Threat Protection.'
}
default: true
}
resource storageAccountName_resource 'Microsoft.Storage/storageAccounts@2018-07-01' = {
name: storageAccountName
location: location
sku: {
name: storageAccountReplication
}
kind: storageAccountKind
properties: {}
}
resource storageAccountName_Microsoft_Security_current 'Microsoft.Storage/storageAccounts/providers/advancedThreatProtectionSettings@2019-01-01' = if (advancedThreatProtectionEnabled) {
name: '${storageAccountName}/Microsoft.Security/current'
properties: {
isEnabled: true
}
dependsOn: [
storageAccountName_resource
]
}
output storageAccountName_output string = storageAccountName I tweaked it just a bit to get rid of the dependsOn by introducing a symbolic reference to the atp extension resource: param storageAccountName string {
metadata: {
description: 'The name must be unique across all existing storage account names in Azure. It must be 3 to 24 characters long, and can contain only lowercase letters and numbers.'
}
default: 'atpstorage${uniqueString(resourceGroup().id)}'
}
param location string {
metadata: {
description: 'Storage account location, default is same as resource group location.'
}
default: resourceGroup().location
}
param storageAccountKind string {
allowed: [
'StorageV2'
'Storage'
]
metadata: {
description: 'Storage account type, for more info see \'https://docs.microsoft.com/en-us/azure/storage/common/storage-account-overview\'.'
}
default: 'StorageV2'
}
param storageAccountReplication string {
allowed: [
'Standard_LRS'
'Standard_GRS'
'Standard_ZRS'
'Premium_LRS'
]
metadata: {
description: 'Storage account replication, for more info see \'https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy\'.'
}
default: 'Standard_LRS'
}
param advancedThreatProtectionEnabled bool {
metadata: {
description: 'Enable or disable Advanced Threat Protection.'
}
default: true
}
resource storageAccountName_resource 'Microsoft.Storage/storageAccounts@2018-07-01' = {
name: storageAccountName
location: location
sku: {
name: storageAccountReplication
}
kind: storageAccountKind
properties: {}
}
resource storageAccountName_Microsoft_Security_current 'Microsoft.Storage/storageAccounts/providers/advancedThreatProtectionSettings@2019-01-01' = if (advancedThreatProtectionEnabled) {
name: '${storageAccountName_resource.name}/Microsoft.Security/current'
properties: {
isEnabled: true
}
}
output storageAccountName_output string = storageAccountName |
Beta Was this translation helpful? Give feedback.
Have you tried using the
bicep decompile
command? You can also use the decompile capability in the bicep playground:Here's the code it generated: