The usual way to create a connection string in appsettings.json is:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(local); Database=MyProperty; Trusted_Connection=True;"
}
}
I want to replace the connection string value with my QA database within a DevOps Release Pipeline.
If I declare a Release Pipeline Variable in Azure Devops I can use the name ConnectionStrings.DefaultConnection, set it a value and it will inject the value into appsettings as part of the release as below:
However if instead of the above, I want to use Azure Key Vault and I create a Key Vault secret, I can only create the secret name as DefaultConnection as period's are not allowed within the secret name and therefore the connection string does not get replaced with the secret value during the release. I presumed that if I could create a secret as ConnectionStrings.DefaultConnection it would work but we are not allowed to add special characters.
Even if I add Variable Group, it takes the secret name which cannot accept special characters as below:
Is there a way I can achieve this please?