I am running a powershell script in Azure function App. The script creates an action group and metric alerts on a cosmosDB container, But the action group creation command fails, i tried with both resourceGroup name and ResourceId , it still fails.
command :
$RID = (Get-AzResource -ResourceType $containerResourceType -ApiVersion $apiVersion -ResourceGroupName $ResourceGroup -Name $containerResourceName).ResourceId
$email1=New-AzActionGroupReceiver -Name $name -EmailReceiver -EmailAddress $Eid
$email2=New-AzActionGroupReceiver -Name $name1 -EmailReceiver -EmailAddress $Eid2
Set-AzActionGroup -ResourceId $RID -ShortName "DAEAG" -Receiver $email1,$email2
I tried the Set-AzActionGroup command with resourceGroup (name) as well, it gives the same error which is,
[Error] ERROR: Set-AzActionGroup : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'Forbidden'
Note : Azure function app connects to Azure subscription using managed Identity fucntion App onject_id is added to roles in cosmosdb account.