I am stumbling on the following problem:
- I have a script that creates the automation response rules for a specific tenant.
Now this works like a charm when the Logic App is in the same tenant and subscription.
But I am stumbling on the error that a different tenant with a different subscription does not accept it because it is missing Microsoft.SecurityInsights/alertRules/read permissions.
I know this is manually possible by navigating to the automation tab and creating the automated response there and selecting the playbook, but it doesnt work with the Powershell script I have written.
My questions:
- Is it possible at all to add an automation rule with a logic app located at a different tenant?
If yes, how to do so?
The current Powershell Script:
$SentinelConnection = @{
ResourceGroupName = "resourcegroupwithsentinel"
WorkspaceName = "azuresentinel"
}
$LogicAppConnection = @{
ResourceGroupName = "resourcegroupwithlogicappindifferenttenant"
Name = "logicappname"
}
$LogicAppResourceId = Get-AzLogicApp @LogicAppConnection
$LogicAppTriggerUri = Get-AzLogicAppTriggerCallbackUrl @LogicAppConnection -TriggerName "Microsoft_Sentinel_alert"
$AlertRules = Get-AzSentinelAlertRule @SentinelConnection
foreach ($rule in $AlertRules) {
New-AzSentinelAlertRuleAction @SentinelConnection -AlertRuleId $rule.Name -LogicAppResourceId ($LogicAppResourceId.Id) -TriggerUri ($LogicAppTriggerUri.Value)
}
To summarize:
- I want a script that allows a 'Playbook' (a self-created logic app) to be used as an automated response for a different Azure Sentinel environment in a different tenant with a automated Powershell Script.
Example of the error:
Get-AzSentinelAlertRule : The client 'emailaddress' with object id 'objectid' does not have authorization to perform action
'Microsoft.SecurityInsights/alertRules/read' over scope
'/subscriptions/subscriptionid/resourceGroups/resourcegroup/providers/Microsoft.OperationalInsights/workspaces/workspace/providers/Microsoft.SecurityInsights' or
the scope is invalid. If access was recently granted, please refresh your credentials.