Azure 应用配置特性管理

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

Azure App Configuration Feature Management

问题

我正在寻找一个使用Maven和Java(不是Spring)的解决方案,我可以通过Json上传所有的关键字、标签和标志值以进行部署。
当我在Jenkins中配置我的项目时,它应该应用所有已更改的值。

请提供一些指导方向,我在这个主题上尝试了很多,但材料较少。

英文:

I am looking for a solution using Maven and Java (Not Spring) where I can upload all my Key and labels and flag value by Json to deploy.
When I configure my project in Jenkins it should apply all the values which are changed.

Kindly provide me some directions, I tried lot with less material on this topic

答案1

得分: 0

我成功地找到了解决方案基本上遵循这个[Microsoft Azure链接][1]但这个链接并没有完全解决我的问题下面是解决我的问题的代码片段这段代码不适用于测试或生产仅供参考

public void process() {

    String value = "{\"id\": \"test\", \"description\": \"Sample Feature\",\"enabled\": false,\"conditions\": { \"client_filters\": []}}";
    DefaultAzureCredential  credential = new DefaultAzureCredentialBuilder().build();
    ConfigurationClient configurationClient = new ConfigurationClientBuilder()
            .connectionString(END_POINT)
            .buildClient();

    final ConfigurationSetting configurationSetting = new ConfigurationSetting();
    configurationSetting.setKey(format(".appconfig.abc/%s", "abc"));
    configurationSetting.setLabel("lable");
    configurationSetting.setContentType("application/vnd.microsoft.appconfig.ff+json;charset=utf-8");
    configurationSetting.setValue(value);

    configurationClient.addConfigurationSettingWithResponse(configurationSetting, NONE)
}

关键点在于.appconfig.abc”,在这个时间点上我们没有直接调用特性管理的方法但我们可以将键和标签添加到配置中就像我在代码片段中所说的那样但键应为.appconfig.abc”,你可以从门户获取这个信息值应为Json对象如何创建此Json取决于您

总体上在网站周围有很多信息但在Java世界中与Azure相关的信息没有相互连接对任何人可能会有帮助

终结点可以从配置访问密钥中获取

[1]: https://learn.microsoft.com/en-us/java/api/overview/azure/data-appconfiguration-readme?view=azure-java-stable
英文:

I managed to workout the solution. Basically following this Microsoft Azure Link
, but not completely solved my problem by this link though. Below is the Code Snippet which solved my problem. Code is not testable or productionable , this is just for reference.

public void process() {

    String value = "{\"id\": \"test\", \"description\": \"Sample Feature\",\"enabled\": false,\"conditions\": { \"client_filters\": []}}";
    DefaultAzureCredential  credential = new DefaultAzureCredentialBuilder().build();
    ConfigurationClient configurationClient = new ConfigurationClientBuilder()
            .connectionString(END_POINT)
            .buildClient();

    final ConfigurationSetting configurationSetting = new ConfigurationSetting();
    configurationSetting.setKey(format(".appconfig.abc/%s", "abc"));
    configurationSetting.setLabel("lable");
    configurationSetting.setContentType("application/vnd.microsoft.appconfig.ff+json;charset=utf-8");
    configurationSetting.setValue(value);

    configurationClient.addConfigurationSettingWithResponse(configurationSetting, NONE)
    }

Key points here is ".appconfig.abc" , At this point of time we don't have direct call to Feature Management , but we can add Key and labels to configuration as I said in the code snippet but with the Key as ".appconfig.abc" which you can get this info from portal. And the value should be a Json object, how we make this Json is upto you really.

Overall so much of information around the sites but none of them are connected in Java world for Azure. May be helpful to any one.

End Point , one can get from the Configuration Access Keys.

huangapple
  • 本文由 发表于 2020年10月23日 17:47:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/64497704.html
匿名

发表评论

匿名网友

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

确定