2

I have a Spring Boot (2.6.6) application which is connected to the Azure App Configuration. I also use the automated refresh mechanisms from the Azure App Configuration, which works fine - I change a value in Azure App Configuration and also update the sentinel value, then the application detects the changes and update the bean values (properties) by calling the setter methods without restarting the application.

But after I added a class with @EnableGlobalMethodSecurity(prePostEnabled = true), then the refresh mechanisms is not working anymore. Only during startup, the values are set, then never again. I see in the log that the application detects the changes, but never calls the setter of the bean to update the values.

How can I solve this problem to have the automated refresh mechanisms and the PreAuthorize working together?

MethodSecurityConfiguration.class:

@Configuration
@AllArgsConstructor
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class MethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {
...
}



ConfigurationProperties.class:

public interface AppConfigurationProperties {

    void setExample(String example);

    String getExample();
}



AzureAppConfigurationProperties.class:

@Configuration
@ConfigurationProperties(prefix = "config")
public class AzureAppConfigurationProperties implements AppConfigurationProperties {

    private String example;

    @Override
    public void setExample(String example) {
        this.example = example;
    }

    @Override
    public String getExample() {
        return this.example;
    }
}
Lennart
  • 21
  • 1
  • Azure App Configurations auto refresh is based on `ServletRequestHandledEvent`s being triggered. It isn't clear for what you show if anything has changed that. Does manually triggering a refresh work, https://microsoft.github.io/spring-cloud-azure/docs/azure-app-configuration/2.5.0/reference/html/index.html#manual? – mrm9084 Apr 25 '22 at 16:29
  • I haven't tested it with manually triggered. But my case is, that I have a Azure DevOps pipeline, which set values in the Azure App Configurations, also the sentinal value. Then the application detects the changes and updated the values in the objects. As I mentioned, it works fine without the class MethodSecurityConfiguration, but with not really. I see that the application detects the changes and reset also the application context and logs also, which properties are changed in Azure App Configuration, but it never called the setter :-( – Lennart Apr 27 '22 at 06:41

0 Answers0