'How to find ObjectId of Service Principal AAD

How to find object id of Service Principal (App Registration) by name in Azure ARM Template.

For DataFactory object id can be retrieved using:

 "objectId":"[reference(resourceId('Microsoft.DataFactory/factories/', parameters('dataFactoryName')), '2018-06-01', 'Full').identity.principalId]",


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source