Home > Blockchain >  Get-AzMetricAlertRuleV2 with managed identity forbidden
Get-AzMetricAlertRuleV2 with managed identity forbidden

Time:01-27

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:

enter image description here

To solve the above you can either provide enter image description here

  •  Tags:  
  • Related