What you are referring to I believe is Managed Identities If that is the case then it is best practice to give access to the identity of the Web App over a service principal as there is no password to be exchanged and the identity exists the lifetime of the app.
The Managed Identity behind the scenes uses a thumbprint to recognize that the app is who it says it is.
If assigning to an Azure Key Vault the access Policy would need to be updated and can be assigned via ARM with the following:
"objectId": "[reference(resourceId('Microsoft.Web/sites', INSERT APP SERVICE NAME), '2018-02-01', 'Full').identity.principalId]"
One important call out is if creating the app service and the Key Vault via the same ARM template then a dependsOn will be needed on the Key Vault depending on the App Service. Wouldn't want to create an access policy for an ID that hasn't been created it.
If assigning an Managed Identity and RBAC role via ARM here is one solution that illustrates assigning an App Service the Azure built in Contributor role to a specific storage account. In the variable section define your Role Name and RoleID:
"Contributor": {
"RoleID": "[concat(variables('roleDefinition'), 'b24988ac-6180-42a0-ab88 20f7382dd24c')]",
"RoleName": "Contributor"
}
Then this would assigned in an ARM template with:
{
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2018-09-01-preview",
"name": "[concat(variables('storageName'), '/Microsoft.Authorization/', guid(uniqueString(variables('storageName'),variables('Reader').RoleName,parameters('principalId'))))]",
"properties": {
"roleDefinitionId": "[variables('Contributor').RoleID]",
"principalId": "[reference(resourceId('Microsoft.Web/sites', variables('webSiteName')), '2018-02-01', 'Full').identity.principalId]"
}
}
Again make sure the dependsOn are correctly identified if building/assigning via the same ARM template.
Throwing this out there too, if using slots each slot will have it's own Managed Identity which will stay with the slot. So Slot-A will always be provisioned access as Slot-A and will not swap when the slot switches.