Hi @Rotem ben hemo ,
Thanks for using Microsoft Q&A !!
It is unfortunately not possible to get service principal Id directly in ARM template. If the service principal is of a managed identity supported service then you can use Identity.principalId
to refer to the same. So, if managed identity is of a VM then you can use something like below -
"[reference(resourceId('Microsoft.Compute/virtualMachines', variables('vmName')),'2019-12-01', 'Full').identity.principalId]"
Please refer to the documentation over here.
Also, you can directly refer User Assigned Managed Identities in your ARM template by using resource type as 'Microsoft.ManagedIdentity/userAssignedIdentities'
and explicitly mentioning principalType
as "ServicePrincipal". Please refer to the documentation for details. Please let me know if you see any issues with this.
Thanks
Saurabh