I'm trying to run an Azure CLI Command to restore Diagnostics settings for a Firewall and I get the error: Failed to parse string as JSON
Loading the segment of Json from an object:
$metrics = ($fwDiagnostics.metrics) | ConvertTo-Json -Compress
Yields:
{"category":"AllMetrics","enabled":true,"retentionPolicy":{"days":90,"enabled":false},"timeGrain":null}
Which looks fine.
But when I run the following command:
az monitor diagnostic-settings create --name $fwDiagnostics.name --metrics $metrics --workspace $fwDiagnostics.workspaceId --resource $resource.id
I get:
Failed to parse string as JSON: {category:AllMetrics,enabled:true,retentionPolicy:{days:90,enabled:false},timeGrain:null} Error detail: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Which appears to have stripped out any ""
around the text elements