How to store API Password and Connection string securely inside Azure Function

john john Pter 950 Reputation points
2025-03-17T14:35:48.97+00:00

I have an Azure Function that runs on daily bases at 11 pm.

The Azure Function will mainly do the following:-

  1. Call an external API end point, where i need to pass the API Username + API Password
  2. Store the API data inside SQL server on Azure. for this I am using a connection string that has username/password

So my question, is how i can securely store those data? mainly the api username/password + database connection string? will simply storing them inside the local.settings.josn will make sure it is stored securely ?

Thanks

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,668 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Loknathsatyasaivarma Mahali 1,290 Reputation points Microsoft External Staff
    2025-03-17T21:41:29.6266667+00:00

    Hello john john Pter,
    While storing sensitive information in local.settings.json is suitable for local development, it should not be used for production secrets. Always ensure that your production secrets are stored securely, using methods like Application Settings or Azure Key Vault.

    • Application Settings: Store your API credentials and connection strings in the application settings of your Azure Function app. These settings are encrypted and securely stored in Azure, which helps prevent accidental disclosure of sensitive information in your code.
    • Azure Key Vault: For enhanced security, consider using Azure Key Vault to manage your secrets. This service allows you to store and control access to sensitive information, such as API passwords and connection strings. You can reference these secrets in your application settings, reducing the risk of exposure.

    Note: If your Azure Function needs to access other Azure services, consider using managed identities. This feature allows your function to authenticate to Azure services without the need to manage secrets directly, further enhancing security.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.