Add Diagnostic Settings to Azure Storage account via Terraform
So you want to add a diagnostic setting to your Azure storage account via Terraform and you pass the storage account ID to target_resource_id
only to get the following error:
Status=400 Code=“BadRequest” Message=“Category ‘StorageWrite’ is not supported.”
Here is the fix, the diagnostic target resource actually needs to be a sub-resource of the storage account, the ID for that is constructed as:
/blobServices/default/
Using this you can create a terraform file similar to the below and it will create the diagnostic setting for you on the blob account.
For a more detailed explanation the issue here goes into more detail.
https://gist.github.com/lawrencegripper/b05872a6d3d72641c7a276c8c1357d53