Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS JSON variable substitution with secrets from Azure Key Vault

I'm doing an Azure App Service Deploy (ASP.NET Core 2.0 Web Api) in Visual Studio Team Services and want to replace some values in the appsettings.json so I read https://docs.microsoft.com/en-us/vsts/build-release/tasks/transforms-variable-substitution#jsonvarsubs, but they talk about substituting values in nested levels of the file, by concatenate the names with a period (.).

Problem is that you can't use periods (.) in an Azure Key Vault.

Does anyone know how to substitute variables with nested levels in an appsettings.json file using Secrets from the Azure Key Vault?

like image 776
Erwin Avatar asked Dec 12 '17 15:12

Erwin


1 Answers

I ended up using 'ConnectionStrings--Database' as Secret key in Azure Key Vault.

Then adding a 'Variable Group' in VSTS (https://docs.microsoft.com/en-us/vsts/build-release/concepts/library/variable-groups) linking to the Azure Key Vault.

And add a 'Process Variable' called ConnectionStrings.Database with a value of '$(ConnectionStrings--Database).

That way it replaces the value of your 'Process Variable' with the value from the Azure Key Vault and it uses the name of the 'Process Variable' to replace in the appsettings.json.

like image 163
Erwin Avatar answered Sep 30 '22 06:09

Erwin