public static void main ( String [ ] args ) throws NoSuchAlgorithmException , InvalidKeyException { // The connection string value can be obtained by going to your App Configuration instance in the Azure portal // and navigating to "Access Keys" page under the "Settings" section. final String connectionString = "endpoint={endpoint_value};id={id_value};name={secret_value}" ; final HttpMethodRequestTracker tracker = new HttpMethodRequestTracker ( ) ; // Instantiate a client that will be used to call the service. // We add in a policy to track the type of HTTP method calls we make. // We also want to see the Header information of our HTTP requests, so we specify the detail level. final ConfigurationAsyncClient client = ConfigurationAsyncClient . builder ( ) . credentials ( new ConfigurationClientCredentials ( connectionString ) ) . addPolicy ( new HttpMethodRequestTrackingPolicy ( tracker ) ) . httpLogDetailLevel ( HttpLogDetailLevel . HEADERS ) . build ( ) ; // Adding a couple of settings and then fetching all the settings in our repository. final List < ConfigurationSetting > settings = Flux . concat ( client . addSetting ( new ConfigurationSetting ( ) . key ( "hello" ) . value ( "world" ) ) , client . setSetting ( new ConfigurationSetting ( ) . key ( "newSetting" ) . value ( "newValue" ) ) ) . then ( client . listSettings ( new SettingSelector ( ) . key ( "*" ) ) . collectList ( ) ) . block ( ) ; // Cleaning up after ourselves by deleting the values. final Stream < ConfigurationSetting > stream = settings == null ? Stream . empty ( ) : settings . stream ( ) ; Flux . merge ( stream . map ( client :: deleteSetting ) . collect ( Collectors . toList ( ) ) ) . blockLast ( ) ; // Check what sort of HTTP method calls we made. tracker . print ( ) ; }
Runs the sample algorithm and demonstrates how to add a custom policy to the HTTP pipeline .