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:
<StorageAccountId>/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.