如何在Java、Spring中始终加载Azure应用配置中没有标签的功能标志。

huangapple go评论77阅读模式
英文:

How to always load feature flags with No Label in azure app config in Java, Spring

问题

I am using azure app configurations to store my feature flags.
By default feature flags are loaded as per the current profile, set in application.yaml like:

spring.profile.active

Now, my deployment environments has seperate instances of azure app config for dev, pre and prod.

So, I want if my application is running on dev environment then it should be able to load both No Label and dev label. Like if some one has defined keys only with No label then it should also work and should be able to fetch value.

This can be worked with app config by providing:

spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filter: ",${spring.profiles.active}"

but providing same with feature flags doesn't work:

spring.cloud.azure.appconfiguration.stores[0].feature-flags.label-filter:",${spring.profiles.active}"

Can any suggest the way to load No Label flag when spring.profile.active has some value.

英文:

I am using azure app configurations to store my feature flags.
By default feature flags are loaded as per the current profile, set in application.yaml like:

spring.profile.active 

Now, my deployment environments has seperate instances of azure app config for dev, pre and prod.

So, I want if my application is running on dev environment then it should be able to load both No Label and dev label. Like if some one has defined keys only with No label then it should also work and should be able to fetch value.

This can be worked with app config by providing:

spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filter: ",${spring.profiles.active}"

but providing same with feature flags doesn't work:

spring.cloud.azure.appconfiguration.stores[0].feature-flags.label-filter:",${spring.profiles.active}"

Can any suggest the way to load No Label flag when spring.profile.active has some value.

答案1

得分: 1

你正在使用的库版本是多少?那个配置设置看起来像是旧版本。如果您升级到最新版本:

对于Spring Framework 2

<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>spring-cloud-azure-appconfiguration-config</artifactId>
    <version>4.8.0</version>
</dependency>

对于Spring Framework 3

<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>spring-cloud-azure-appconfiguration-config</artifactId>
    <version>5.2.0</version>
</dependency>

最新版本支持与功能标志一样的加载方式,详见此处的最后一个表格:https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/spring/spring-cloud-azure-starter-appconfiguration-config#supported-properties

英文:

What version of your library are you using, that configuration setup looks like an old one. If you updated to the latest:

For Spring Framework 2
&lt;dependency&gt;
    &lt;groupId&gt;com.azure.spring&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-azure-appconfiguration-config&lt;/artifactId&gt;
    &lt;version&gt;4.8.0&lt;/version&gt;
&lt;/dependency&gt;

For Spring Framework 3
&lt;dependency&gt;
    &lt;groupId&gt;com.azure.spring&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-azure-appconfiguration-config&lt;/artifactId&gt;
    &lt;version&gt;5.2.0&lt;/version&gt;
&lt;/dependency&gt;

The latest versions support the same loading style for feature flags as configurations, see the last table here https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/spring/spring-cloud-azure-starter-appconfiguration-config#supported-properties

答案2

得分: 0

这可以通过以下方式实现:

spring.cloud.azure.appconfiguration.stores[0].feature-flags.selects[0].label-filter = ",${spring.profiles.active}"

英文:

This can be achieved by setting:

spring.cloud.azure.appconfiguration.stores[0].feature-flags.selects[0].label-filter = ",${spring.profiles.active}"

huangapple
  • 本文由 发表于 2023年6月27日 17:42:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76563580.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定