Reputation: 43
I am supporting an Azure Function someone wrote in C# in .NET Core 2.2.4. The function app is connecting to a database using a SQL Server account, and username and password are hardcoded in the connection string at the moment. We want to use Azure Keyvault now so that we don't have the password in the connection string.
Here is the connection with hardcode username and password in local.setting.json file
:
"SQLConnectionString":"Server=tcp:xxxx-sql.database.windows.net,1433;Initial Catalog=abc-db;Persist Security Info=False;User ID=xxxx;Password=xxxxxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Upvotes: 0
Views: 1242
Reputation: 11363
If your Username and Password are in KeyVault Secrets then You should give access to use the secrets as below reference:
In configuration section Of function app Click on Add Application Setting and Then type password and then below code
@Microsoft.KeyVault(SecretUri=https://mykeyvaultname.vault.azure.net/secrets/mysecretname/)
Then codes for using inside Azure Function are reference1 and reference2.
Upvotes: 0