如何限制从 Spring 引导应用程序向 Azure 应用程序配置发出的请求数?

How to limit the number of requests being made to Azure App Configuration from a Spring Boot application?

我在 Azure Web 应用程序实例上有一个 Spring 启动应用程序 运行,它被设置为从应用程序配置中获取外部配置。

我正在使用应用程序配置的免费层,这应该足以满足我的需求,因为我的应用程序不需要频繁更新其配置属性。

该应用对应用配置服务进行了数千次调用,导致我达到了我的服务配额,因此我经常看到 http 429 错误。

我发现 this article 解决了如何为我的应用程序属性配置更长的超时时间,但它是特定于 .NET 的,对使用 Spring 引导的应用程序配置 SDK 的人没有帮助.

这取决于您使用的 Azure 应用程序配置库的版本。如果是 2.0.0 或更高版本,您可以在此处找到配置 https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-spring-cloud-starter-appconfiguration-config#supported-properties. Or if it is an older version https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/spring-cloud-starter-azure-appconfiguration-config#supported-properties.

因此,2.0.0 的配置应为 spring.cloud.azure.appconfiguration.stores[0].monitoring.watch-interval,1.X.X 版本的配置应为 spring.cloud.azure.appconfiguration.cache-expiration

此外,根据您的情况,如果您使用的是 2.0.0 库,您可能需要考虑使用基于推送的刷新。