I have an appsettings.json
file where I want to transform the value located at:
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=MyDatabase;Trusted_Connection=True;MultipleActiveResultSets=true"
},
I found the following answer so I know that an app service can retrieve values directly from the key vault:
https://stackoverflow.com/a/59994040/3850405
This is not the reason for asking. Since Microsoft offers JSON variable substitution
I still think this should be possible since the only problem is the nested value. The question above is similar but I would like to specify a bit more what has already been tested and where I got stuck.
It is possible to use Pipelines -> Library -> Variable group
or a Azure Key Vault Task to get the secret value.
The problem is the secret value can not contain dots:
Please provide a valid secret name. Secret names can only contain alphanumeric characters and dashes.
Neither in a linked Variable group or in a Azure Key Vault Task I'm allowed to rewrite a secret name to another variable name.
Looking at the sample below if the secret name was ConnectionStringsDefaultConnection
I could access the value like this $(ConnectionStringsDefaultConnection)
but I don't know how to rename it.
https://azuredevopslabs.com/labs/vstsextend/azurekeyvault/
I have found a task that could get the job done but it requires a third party Release task. This is not acceptable since the project only allows Tasks written by Microsoft.
I also know that a Pipeline variable can be used to store the value but we wan't to have a single source of truth and that is the Azure Key Vault Secret.