Home > Enterprise >  How can I hide username and password in connection string in Azure App Service?
How can I hide username and password in connection string in Azure App Service?

Time:01-07

I have an app service and in the Configuration section there is a connection string that connect to a database as follows:

Server=tcp:myserver.database.windows.net,1433;Database=myDataBase;User 
ID=mylogin@myserver;Password=myPassword;Trusted_Connection=False;Encrypt=True;

How can I hide the plain text password utilizing Azure services or anything else?

CodePudding user response:

Azure Key Vault is a good way to hide credentials in connection strings in an Azure Web App. Here's an overview of the steps you can follow:

  1. Create an Azure Key Vault instance.
  2. Add the connection strings you want to store as secrets in the Key Vault.
  3. Grant access to the Azure Web App to retrieve secrets from the Key Vault.
  4. In the Azure Web App, retrieve the connection strings from the Key Vault at runtime.

CodePudding user response:

As a general approach: Use Key Vault-referenced App Settings in Azure App Service.

Your preferred way, however, should be to use Managed Identity of the App Service and then use Azure AD-based authentication for all services which support it (Azure SQL does).

  • Related