I am trying to run a powershell command in my azure runbook. But I am getting a forbidden exception... Probably due to insufficient permissions. But where can I find the permissions I need?
$AzureContext = (Connect-AzAccount -Identity -AccountId "<accountidguid>").context
Get-AzMetricAlertRuleV2 -ResourceGroupName $resourceGroupName -Name "myalertname" | Add-AzMetricAlertRuleV2 -DisableRule:$true -TargetResourceRegion " "
Exception type: ErrorResponseException, Message: Null/Empty, Code: Null, Status code:Forbidden, Reason phrase: Forbidden
CodePudding user response:
I tested it in my environment by providing the managed identity Reader role in my subscription . I was able to get the alert rule but not able to perform the Add-AzMetricAlertRuleV2 which errored out like below:


