VSTS JSON变量替换为Azure Key Vault中的机密 [英] VSTS JSON variable substitution with secrets from Azure Key Vault

查看:67
本文介绍了VSTS JSON变量替换为Azure Key Vault中的机密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio Team Services中进行Azure应用服务部署(ASP.NET Core 2.0 Web Api),并且想要替换appsettings.json中的某些值,因此我阅读

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 (.).

问题是您不能在Azure Key Vault中使用句点(.).

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

有人知道如何使用Azure Key Vault中的Secrets在appsettings.json文件中用嵌套级别替换变量吗?

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

推荐答案

我最终在Azure Key Vault中使用"ConnectionStrings--Database"作为密钥.

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

然后在VSTS中添加变量组"(

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.

并添加一个名为"ConnectionStrings.Database"的过程变量",其值为"$(ConnectionStrings--Database)".

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

这样,它将流程变量"的值替换为Azure Key Vault中的值,并使用流程变量"的名称替换appsettings.json中的内容.

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.

这篇关于VSTS JSON变量替换为Azure Key Vault中的机密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆