There's really good documentation here that you can follow : https://learn.microsoft.com/en-us/azure/azure-functions/functions-identity-access-azure-sql-with-managed-identity#grant-sql-database-access-to-the-managed-identity
The key steps
- Enable Managed Identity on the Function App
- Add the appropriate SQL Roles.
CREATE USER [<identity-name>] FROM EXTERNAL PROVIDER; ALTER ROLE db_datareader ADD MEMBER [<identity-name>];
- Save the connection string in your Function App AppSettings.