Search code examples
azureazure-service-fabricazure-resource-manager

Referencing an Azure AD service principal ID within an ARM template


Is there a way to get an Azure AD Service Principal ID with an in-built ARM template function? I'm looking for the ARM equivalent of Get-AzADServicePrincipal -DisplayName "Azure Service Fabric Resource Provider" and drawing a blank.

Context: I'm following a tutorial on deploying a Service Fabric managed cluster using an existing load balancer, and the tutorial requests that you run a powershell command to get the resource provider's service principal ID and then hard-code said ID in the ARM template. This ID is expected to vary by tenant, and the same template will be deployed to multiple tenants.


Solution

  • For some Azure resources, you can use the reference template function with the full parameter to retrieve identity properties.

    However, there is no generic way to retrieve a service principal ID within ARM. The Get-AzADServicePrincipal powershell cmdlet requires Azure AD graph permissions, which cannot be granted to user assigned MSIs within ARM templates at this time.