I'm adding Diagnostic Settings via (Az) PowerShell to a LogicApp using the below powershell command, however, nothing is created in the diagnostic setting of the resource.
$LogicApp = "/subscriptions/dc4e35b0-3a98-41a6-86a0-e83de3d06b2e/resourceGroups/Lieblik/providers/Microsoft.Logic/workflows/logic-lieblik-sitepoolingscheduler"
$Workspace = Get-AzOperationalInsightsWorkspace -Name "BO-Crayon-LAW" -ResourceGroupName "commonservices"
New-AzDiagnosticSetting -ResourceId $LogicApp -WorkspaceId $Workspace.ResourceId -Name "DiagMonitor"
I waited hours to check if it was due to some delay, but no luck!.
Below is the script
which worked for me:
$RithResourceId = "/subscriptions/b83c84c23f/resourceGroups/vbojja/providers/Microsoft.Logic/workflows/rith6"
$RithWorkspc = Get-AzOperationalInsightsWorkspace -Name "rit54-workspacename" -ResourceGroupName "rgname"
$RithWkId= $RithWorkspc.ResourceId
$DiagnosticSettingName = "RithTesting"
$rithmetrics = New-AzDiagnosticSettingMetricSettingsObject -Enabled $true -Category AllMetrics
New-AzDiagnosticSetting -Name $DiagnosticSettingName -ResourceId $RithResourceId -WorkspaceId $RithWkId -Metric $rithmetrics
$RithResourceId is the resource id of the resource where you want to create diagnostic setting.
Output: