I’m new to Azure Cloud. I’m trying to assign user assigned managed identity to Azure Sql Server for Function App Resource. I have added User who can access Azure Sql Server. Simultaneously I had tried to turn on system identity.
What is exactly being happened is:
- When I turn on System Identity it shows Login for User ” error.
- When I turn off System Identity it shows unable to load the proper Managed Identity.
- I actually need User Assigned Identity. So for that I tried below command in SQL Server
I created a user namely UMI1 and added this user in User assigned managed identity.
CREATE USER [UMI1] FROM EXTERNAL PROVIDER; GO ALTER ROLE db_datareader ADD MEMBER [UMI1]; ALTER ROLE db_datawriter ADD MEMBER [UMI1]; GO
Connection string contains User ID=UM1
So, I think I having problem in creating user in sql. Any reference or response regarding this issue would be helpful. Thank you in advance
2
Answers
I have tried with the System Assigned Managed Identity:
Next the below Query executed:
Here
PravisNet6FunApp
is the Function App Name.Next, Modified the Function Code for fetching the access token using SQL Connection:
In the
local.settings.json
, SQL Connection is defined., Published to Azure Portal Function App and defined the connection string under Function App > Configuration:If you are using the
Microsoft.Data.SqlClient
library (see nuget), you can configure the connectionstring to use managed identity:The connectionstring will looks like that:
When using user-assigned identity, you can specify the client_id by adding an extra connection property: