I am attempting to use bicep to replicate the following scenario:
- An Azure SQL instance with a single database
- An Azure function which needs to connect to that database via managed identity.
As it stands, once the infrastructure is deployed we have to use SSMS or similar to add the relevant roles:
CREATE USER [functioName] FROM EXTERNAL PROVIDER
ALTER ROLE db_datareader ADD MEMBER [functionName]
I have been investigating a way to do this within bicep itself but have not been able to get it to work, I have attempted to create a user managed identity with a contributor role and used that identity in a deployment script containing powershell to run InvokeSQL against the dB but am running into errors.
I'm unsure if this is the right way to go about it or if this is possible at all in bicep, so any guidance would be appreciated.