I have setup the Key-Vault secret in Azure for connection string and updated my web config file as shown below and it is working fine. Now my question is if I need to provide a separate connection string for QA, dev, staging or other environment, prior to deploy to the to the Azure app service would I manually update the connection string name? Is there any way that I don't have to change the name as per the environment. (I am doing the deployment manually and CI/CD is not involved>
<connectionStrings configBuilders="AzureKeyVault">
<add name="ProductionConnstr" connectionString="from key vault"
providerName="System.Data.SqlClient" />
</connectionStrings>
Edit:
I have used the connected service to generate and to get the nuget package. The code run fine and connection string is being picked from the Key Vault secret but when I am getting error when deploying the code to web app. Below is the auto generated code. I wonder if I am missing something else that is needed. I am using MVC 4.7.2
Error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed.
web config code.
<configSections><section name="configBuilders"
type="System.Configuration.ConfigurationBuildersSection,
System.Configuration, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f22d50a3a"
restartOnExternalChanges="false"
requirePermission="false" />
</configSections>
<configBuilders>
<builders>
<add name="AzureKeyVault" vaultName="Prod-ConSt-01" type
"Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder,
Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf9256ad364e35"
vaultUri="https://mywebsite-prod-const-01.vault.azure.net/" /><
/builders>
</configBuilders>
<connectionStrings configBuilders="AzureKeyVault">
<add name="ProductionConnstr" connectionString="from key vault"
providerName="System.Data.SqlClient" />
</connectionStrings>