public async Task ConfiguringPipeline() { // this instance will hold pipeline creation options var options = new HttpPipeline.Options(); // specify custon HttpClient options.Transport = new HttpClientTransport(s_client); // remove logging policy options.LoggingPolicy = null; // specify custom retry policy options options.RetryPolicy = RetryPolicy.CreateFixed( maxRetries: 10, delay: TimeSpan.FromSeconds(1), retriableCodes: new int[] { 500, // Internal Server Error 504 // Gateway Timeout } ); // add a policy (custom behavior) that executes once per client call options.PerCallPolicies = new HttpPipelinePolicy[] { new AddHeaderPolicy() }; // add a policy that executes once per retry options.PerRetryPolicies = new HttpPipelinePolicy[] { new CustomLogPolicy() }; var connectionString = Environment.GetEnvironmentVariable("AZ_CONFIG_CONNECTION"); // pass the policy options to the client var client = new ConfigurationClient(connectionString, options); await client.SetAsync(new ConfigurationSetting("some_key", "some_value")); await client.DeleteAsync("some_key"); }
public async Task ConfiguringRetries() { // specify retry policy options var options = new PipelineOptions(); options.RetryPolicy = RetryPolicy.CreateFixed( maxRetries: 10, delay: TimeSpan.FromSeconds(1), retriableCodes: new int[] { 500, // Internal Server Error 504 // Gateway Timeout } ); var connectionString = Environment.GetEnvironmentVariable("AZ_CONFIG_CONNECTION"); // pass the policy options to the client var client = new ConfigurationClient(connectionString, options); await client.SetAsync(new ConfigurationSetting("some_key", "some_value")); await client.DeleteAsync("some_key"); }