despite azure documentation I don;t think you can use New-AzRoleAssignment with ApplicationId inplace of of ObjectId
$appId = 'f9f6b23d-eff8-48e1-a7f9-fd636a32e62c' # random GUID - could be web/func app ID
$roleName='Azure Service Bus Data Owner'
New-AzRoleAssignment -ApplicationId $appId -RoleDefinitionName $roleName
Getting error:
Can anyone tell me what I'm missing?
I got the same error message like you:
To resolve the error, you need to give application_id for your Service Principal means Application_id of that Enterprise Application.
I ran same powershell command:
$appId = '<application_id of your Service Principal> '
$roleName='Azure Service Bus Data Owner'
New-AzRoleAssignment -ApplicationId $appId -RoleDefinitionName $roleName
Response:
I verified it from portal as well:
Reference:
Application and service principal objects in Microsoft Entra ID