How to deploy Microsoft Defender for a storage account with bicep

Christopher Solum-Faeste 25 Reputation points
2024-04-03T13:26:14.27+00:00

I'm trying to use bicep to enable Microsoft Defender for Cloud for a storage account in Azure. However, the defender is enabled but the "On-upload malware scanning" is not enabled even though I set the property to "true" in the bicep file.

I have been using the template from https://video2.skills-academy.com/en-us/azure/defender-for-cloud/defender-for-storage-infrastructure-as-code-enablement?tabs=enable-storage-account#bicep-template---storage-account

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' ...
resource defenderForStorageSettings 'Microsoft.Security/DefenderForStorageSettings@2022-12-01-preview' = {
  name: 'current'
  scope: storageAccount
  properties: {
    isEnabled: true
    malwareScanning: {
      onUpload: {
        isEnabled: true
        capGBPerMonth: 5000
      }
    }
    sensitiveDataDiscovery: {
      isEnabled: true
    }
    overrideSubscriptionLevelSettings: true
  }
}


Anybody that stumble upon this issue before and have a solution?

Microsoft Defender for Cloud
Microsoft Defender for Cloud
An Azure service that provides threat protection for workloads running in Azure, on-premises, and in other clouds. Previously known as Azure Security Center and Azure Defender.
1,373 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 24,051 Reputation points MVP
    2024-04-03T13:48:23.7333333+00:00

    Hi,

    This is the correct method. How have you identified that is not applied? Did you also enabled the Defender for Storage plan on the subscription where the storage account is located?

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.