Database connection string with azure keyvault in azure function local.setting.json

OS 0 Reputation points
2023-03-03T21:01:36.3+00:00

Hi,

I am supporting an azure function someone wrote in c# in donnet frameworkcore 2.2.4. The function app is connecting to database using sql account and usernames and passwords are hardcode in connection string at the moment. We want to use azure keyvault now so that we dont have list password in 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;"

Can you help me, how can I replace this connection string so that it gets username and password from Key vault secrets? I dont have much deeper knowledge of C#. Thank you for your help.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,150 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,385 questions
{count} votes