1
votes

What would be the correct sequence to enable diagnostic settings for a resource in Azure?

I was trying Set-AzureRMDiagnosticSettings in Powershell 5.0 to enable the settings on an MSSQL Paas database. But it doesn't seem to be working.

I am using the OMS workspace for diagnostic Settings.

1

1 Answers

2
votes

You could try the command below, it works fine on my side. It enable Diagnostic settings in azure sql database and pass the same to OMS workspace.

$workspaceName = '<OMSworkspaceName>'
$ResourceGroupName = '<ResourceGroupName>'
$oms=Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName $ResourceGroupName -Name $workspaceName
$WSID = $oms.ResourceId
$resource = Get-AzureRmResource -ResourceGroupName <ResourceGroupName> -ResourceType Microsoft.Sql/servers/databases -ResourceName "<sqlservername>/<databasename>"
$resourceId = $resource.ResourceId  
Set-AzureRmDiagnosticSetting -ResourceId $resourceId -WorkspaceId $WSID -Enable $True

enter image description here enter image description here

Check in the portal:

enter image description here