Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,210 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to query log analytics using managed identity of automation account runbook with powershell script not getting any samples for the same ,
same way we have samples for virtual machine managed identity used for accessing keyvault in powershell script.
You could make use the below snippet I spun to query the Log Analytics using the Managed Identity
I am making use of the below commandlet
Invoke-AzOperationalInsightsQuery
The commandlets needs Modules - Az.Accounts & Az.OperationalInsights
param (
[Parameter(Mandatory=$true)]
[String] $WorkSpaceId,
[Parameter(Mandatory=$true)]
[String] $Query
)
#$connectionName = "AzureRunAsConnection"
try
{
# Logging in as Managed Identity
"Logging in to Azure..."
Connect-AzAccount -Identity
}
catch {
"Error Occured while Authenticating"
}
"Executing the query"
$result = Invoke-AzOperationalInsightsQuery -WorkspaceId $WorkSpaceId -Query $Query
"Printing the results"
$result.results
Output :