Share via

How to deploy Microsoft Defender for a storage account with bicep

Christopher Solum-Faeste 30 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://learn.microsoft.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 Security | Microsoft Defender | Microsoft Defender for Cloud
0 comments No comments
{count} vote

Answer accepted by question author
  1. Stanislav Zhelyazkov 29,481 Reputation points MVP Volunteer Moderator
    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.


1 additional answer

Sort by: Most helpful
  1. Steph Locke 0 Reputation points
    2026-03-03T18:08:40.5366667+00:00

    Yes, I'm having the same issue and there's a (super quiet, msft haven't responded) discussion about it at https://github.com/Azure/bicep/discussions/15760

    0 comments No comments

Your answer

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