简体   繁体   English

您可以参考 application.properties 中的 Azure Key Vault 机密吗?

[英]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.

相关问题 在 Springboot 应用程序中从 Azure Key Vault 获取机密时面临问题 - Facing issue with getting secrets from Azure Key Vault in a Springboot Application application.properties中的变量 - Variables inside application.properties Spring在Docker容器中看不到application.properties - Spring can't see application.properties inside a docker container 如何处理 application.properties 文件中的 Docker-Secrets - How to handle Docker-Secrets in application.properties files AWS Secrets for application.properties with Springboot lambda 函数 - AWS Secrets for application.properties with Springboot lambda functions application.properties 中的动态键名 - Dynamic key names in application.properties @Autowired基于application.properties中的属性 - @Autowired based on a property inside application.properties 应用程序运行后,如何检查应用程序的application.properties 中的属性值? - How can you check the value of a property in application.properties for a springboot application after the application is running? 我们可以在Spring Boot中更改application.properties文件中键的值吗? - Can we change the value of a key in application.properties file in spring boot? 在 Java spring application.properties 中将 k8s 机密读取为 env 变量 - Read k8s secrets as env varaible in Java spring application.properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM