Assigning multiple identities to a single Azure Function is possible, but it must be done at the Function App level rather than individual functions. Here's how you can do it:
1. Enable System-Assigned Managed Identity: This is straightforward and can be done by turning it on in the Function App settings. The identity is created with the same name as your Function App and is deleted when the app is deleted[1][7].
2. Assign User-Assigned Managed Identities: You can create multiple User-Assigned Managed Identities and assign them to your Function App. These identities are created and managed independently of the Function App lifecycle, allowing you to manage permissions centrally for multiple resources[1][7].
To assign multiple User-Assigned Managed Identities to a Function App:
- Create the User-Assigned Managed Identities in Azure.
- Go to your Function App in the Azure portal.
- Navigate to the "Identity" tab.
- Click on "User assigned" and then select the identities you want to assign.
- You can assign multiple User-Assigned Managed Identities to a single Function App, but you will need to manage their usage through code or configurations[1][8].
If you need different permissions for individual functions within the same Function App, consider separating them into different Function Apps, each with its own set of managed identities[2].
Citations:
[1] https://www.red-gate.com/simple-talk/cloud/azure/azure-function-and-user-assigned-managed-identities/
[2] https://stackoverflow.com/questions/67691996/can-you-assign-a-user-managed-identity-for-individual-functions-in-a-function-ap
[3] https://techcommunity.microsoft.com/t5/apps-on-azure/how-to-assign-multiple-user-managed-identities-to-azure-web-app/m-p/3752631
[4] https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-functions/functions-identity-based-connections-tutorial.md
[5] https://www.c-sharpcorner.com/article/assign-system-managed-identity-to-azure-function-apps-with-powershell/
[6] https://docs.azure.cn/en-us/entra/identity/managed-identities-azure-resources/managed-identities-faq
[7] https://www.codit.eu/blog/setting-up-authentication-on-azure-functions-using-microsoft-identity-provider/
[8] https://docs.azure.cn/en-us/app-service/overview-managed-identity?context=%2Factive-directory%2Fmanaged-identities-azure-resources%2Fcontext%2Fmsi-context&tabs=portal%2Chttp