Enable Azure Diagnostic Logs Settings
Logging to storage account
$resource = Get-AzResource -Name [resource name] -ResourceGroupName [resource group name]
$storage = Get-AzResource -Name [resource name] -ResourceGroupName [resource group name]
Set-AzDiagnosticSetting –ResourceId $resource.ResourceId –StorageAccountId $storage.ResourceId -Enabled $true
Streaming of diagnostic logs to Event Hub
$rule = Get-AzServiceBusRule -ResourceGroup [resource group name] -Namespace [namespace]
-Topic [topic] -Subscription [subscription] -Name [rule name]
Set-AzureRmDiagnosticSetting -ResourceId $resource.ResourceId -ServiceBusRuleId $rule.Id -Enabled $true
Streaming of diagnostic logs to a Log Analytics workspace
$workspace = Get-AzOperationalInsightsWorkspace -Name [workspace name]-ResourceGroupName [resource group name]
Set-AzureRmDiagnosticSetting -ResourceId $resource.ResourceId -WorkspaceId $workspace.ResourceId -Enabled $true