Securely accessing an SQL database from Azure Functions using Managed Identity
Let's say an employee has changed the password of the account as per their firm's security policy (to rotate the password every month). The applications using that account now wouldn't be able to gain access. For developers, wouldn't it be good if there was a facility where we don't need to worry about the credentials and, instead, the framework took care of authentication? In this recipe, you will learn how to access an SQL database from an Azure function (using Visual Studio) without providing a user ID or password by using a feature called Managed Service Identity.
How to do it...
In this recipe, we are going to perform the following steps:
- Creating a function app using Visual Studio (if not done already)
- Creating an SQL database
- Enabling Managed Service Identity from the portal
- Allowing SQL Server access to the new Managed Service Identity
- Executing...