Hello Aayush Agrawal, I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!
Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer. Accepted answers show up at the top, resulting in improved discoverability for others.
Issue: On-upload malware scanning option is enabled for a storage account but still malware scan is not getting triggered on blob upload.
Error Message:
tried to enable "Override Defender for Storage subscription-level settings" and got below error on first try:
Could not enable on-upload malware scanning: Custom data scanner '/subscriptions/{SubscriptioID}/providers/Microsoft.Security/datascanners/StorageDataScanner' doesn't exists..
Could not enable sensitive data discovery: Custom data scanner '/subscriptions/{SubscriptioID}/providers/Microsoft.Security/datascanners/StorageDataScanner' doesn't exists.
################ Got below error on second try: Plan enablement partially succeeded. Could not enable on-upload malware scanning: Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown..
Could not enable sensitive data discovery: Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown.
Cause: Incorrect Storage type.
Solution: Customer was using Blob storage. After upgrading the Storage from BlobStorage to StorageV2., the issue got mitigated.