Sarabpreet Singh
Sarabpreet Singh

Reputation: 51

Azure Powershell Diagnostics Settings

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.

Upvotes: 1

Views: 917

Answers (1)

Joy Wang
Joy Wang

Reputation: 42043

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

Upvotes: 2

Related Questions