Link Azure Automation Account to OMS Workspace using Powershell
I am trying to generate an OMS Solution using Log Analytics and Azure Automation. However, after I create an Azure Automation account i observe that there is no way to link the Azure Automation account to the Log Analytics workspace. It would be great if this option is available.
Pranav Kumar commented
how to use Invoke-AzOperationalInsightsQuery in automation account as it is not giving any output in automation account. It is giving output in powershell.
Raju, Sunil commented
need a way in powershell cmdlet to link the automation with log analytics.
Need an API or powershell cmdlet to link the automation with OMS workspace
The ask here is "How we could link the automation account to OMS" and not forwarding diagnostic logs from automation account to OMS.
I know that could be done via ARM template
"resourceId": "[resourceId('Microsoft.Automation/automationAccounts/', parameters('omsAutomationAccountName'))]"
But it would be of great help if we could link the Automation account to OMS using powershell.
Balamurugan Shanmugam commented
For Logging & diagnostics you can use
$automationAccountId = (Find-AzureRmResource -ResourceType "Microsoft.Automation/automationAccounts" -ResourceNameContains "AutomationAccountName").ResourceId
$workspaceId = (Get-AzureRmOperationalInsightsWorkspace | Where-Object Name -like ('*'+"your OMS workspace name"+'*')).ResourceId
Set-AzureRmDiagnosticSetting -ResourceId $automationAccountId -WorkspaceId $workspaceId -Enabled $true