[英]Can you reference Azure Key Vault secrets inside application.properties?
I have a record:我有一个记录:
@ConfigurationProperties("service.api")
@ConstructorBinding
public record ServiceApiConfig(String clientId, String clientSecret) {}
and an application.properties file:和一个 application.properties 文件:
service.api.client_id=client_id
service.api.client_secret=client_secret
and the binding works when I'm doing local development.当我进行本地开发时,绑定有效。
What I want to do is to use Azure services (Azure Spring Apps, Key Vault, etc.) and my question is whether I can, inside application.properties file, reference secrets stored in the Key Vault.我想做的是使用 Azure 服务(Azure Spring 应用程序、Key Vault 等),我的问题是我是否可以在 application.properties 文件中引用存储在 Key Vault 中的机密。 Something like this:
像这样的东西:
service.api.client_id=<name-of-the-id-kept-in-the-vault>
service.api.client_secret=<name-of-the-secret-kept-in-the-vault>
Tutorials I've seen make me think that the only way to do the binding is by using @Value("${nameOfTheSecret}")
annotation on fields in java classes.我看过的教程让我认为进行绑定的唯一方法是在 java 类中的字段上使用
@Value("${nameOfTheSecret}")
注释。 Is it possible to do it in a way that I want?是否有可能以我想要的方式做到这一点?
You can reference Azure Key Vault secrets inside the application.properties
file by adding the below properties of azure key vault which you want to connect from the spring boot application:您可以在
application.properties
文件中引用 Azure Key Vault 机密,方法是添加要从 Z2A2D595E6ED9A0B24F027F2B63B134 引导应用程序连接的 azure 密钥库的以下属性:
spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-id=<your client ID>
spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-secret=<your client key>
spring.cloud.azure.keyvault.secret.property-sources[0].endpoint=https://contosokv.vault.azure.net/
spring.cloud.azure.keyvault.secret.property-sources[0].profile.tenant-id=<your tenant ID>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.