英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论