From 901a0488ea3a08a798f3d15703bd2d0bd6a9fad2 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Tue, 19 Nov 2024 09:35:16 -0600 Subject: [PATCH] Link to proxy doc on Learn --- sdk/core/Azure.Core/samples/Configuration.md | 29 +++---------------- .../tests/samples/ConfigurationSamples.cs | 20 ------------- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/sdk/core/Azure.Core/samples/Configuration.md b/sdk/core/Azure.Core/samples/Configuration.md index 75ba94b58ed80..29a843dbcfca5 100644 --- a/sdk/core/Azure.Core/samples/Configuration.md +++ b/sdk/core/Azure.Core/samples/Configuration.md @@ -22,7 +22,7 @@ SecretClientOptions options = new SecretClientOptions() ## Setting a custom retry policy -Using `RetryOptions` to configure retry behavior is sufficient for the vast majority of scenarios. For more advanced scenarios, it's possible to use a custom retry policy by setting the `RetryPolicy` property of client options class. This can be accomplished by implementing a retry policy that derives from the `RetryPolicy` class, or by passing in a `DelayStrategy` into the existing `RetryPolicy` constructor. The `RetryPolicy` class contains hooks to determine if a request should be retried and how long to wait before retrying. +Using `RetryOptions` to configure retry behavior is sufficient for the vast majority of scenarios. For more advanced scenarios, it's possible to use a custom retry policy by setting the `RetryPolicy` property of client options class. This can be accomplished by implementing a retry policy that derives from the `RetryPolicy` class, or by passing in a `DelayStrategy` into the existing `RetryPolicy` constructor. The `RetryPolicy` class contains hooks to determine if a request should be retried and how long to wait before retrying. In the following example, we implement a policy that will prevent retries from taking place if the overall processing time has exceeded a configured threshold. Notice that the policy takes in `RetryOptions` as one of the constructor parameters and passes it to the base constructor. By doing this, we are able to delegate to the base `RetryPolicy` as needed (either by explicitly invoking the base methods, or by not overriding methods that we do not need to customize) which will respect the `RetryOptions`. @@ -68,7 +68,7 @@ SecretClientOptions options = new SecretClientOptions() }; ``` -Another scenario where it may be helpful to use a custom retry policy is when you need to customize the delay behavior, but don't need to adjust the logic used to determine whether a request should be retried or not. In this case, it isn't necessary to create a custom `RetryPolicy` class - instead, you can pass in a `DelayStrategy` into the `RetryPolicy` constructor. +Another scenario where it may be helpful to use a custom retry policy is when you need to customize the delay behavior, but don't need to adjust the logic used to determine whether a request should be retried or not. In this case, it isn't necessary to create a custom `RetryPolicy` class - instead, you can pass in a `DelayStrategy` into the `RetryPolicy` constructor. In the below example, we create a customized delay strategy that uses a fixed sequence of delays that are iterated through as the number of retries increases. We then pass the strategy into the `RetryPolicy` constructor and set the constructed policy in our options. ```C# Snippet:SequentialDelayStrategy @@ -153,7 +153,7 @@ SecretClientOptions options = new SecretClientOptions() ``` > **_A note to library authors:_** -Library-specific response classifiers _will_ be respected if a user sets a custom policy deriving from `RetryPolicy` as long as they call into the base `ShouldRetry` method. If a user doesn't call the base method, or sets a `HttpPipelinePolicy` in the `RetryPolicy` property, then the library-specific response classifiers _will not_ be respected. +Library-specific response classifiers _will_ be respected if a user sets a custom policy deriving from `RetryPolicy` as long as they call into the base `ShouldRetry` method. If a user doesn't call the base method, or sets a `HttpPipelinePolicy` in the `RetryPolicy` property, then the library-specific response classifiers _will not_ be respected. ## User provided HttpClient instance @@ -168,25 +168,4 @@ SecretClientOptions options = new SecretClientOptions ## Configuring a proxy -```C# Snippet:HttpClientProxyConfiguration -using HttpClientHandler handler = new HttpClientHandler() -{ - Proxy = new WebProxy(new Uri("http://example.com")) -}; - -SecretClientOptions options = new SecretClientOptions -{ - Transport = new HttpClientTransport(handler) -}; -``` - -## Configuring a proxy using environment variables - -You can also configure a proxy using the following environment variables: - -* `HTTP_PROXY`: the proxy server used on HTTP requests. -* `HTTPS_PROXY`: the proxy server used on HTTPS requests. -* `ALL_PROXY`: the proxy server used on HTTP and HTTPS requests in case `HTTP_PROXY` or `HTTPS_PROXY` are not defined. -* `NO_PROXY`: a comma-separated list of hostnames that should be excluded from proxying. - -**Warning:** setting these environment variables will affect every new client created within the current process. +This guidance has moved to [Configure a proxy when using the Azure SDK for .NET](https://learn.microsoft.com/dotnet/azure/sdk/configure-proxy). diff --git a/sdk/core/Azure.Core/tests/samples/ConfigurationSamples.cs b/sdk/core/Azure.Core/tests/samples/ConfigurationSamples.cs index 3154bbb88e081..d547fa61967f6 100644 --- a/sdk/core/Azure.Core/tests/samples/ConfigurationSamples.cs +++ b/sdk/core/Azure.Core/tests/samples/ConfigurationSamples.cs @@ -2,9 +2,7 @@ // Licensed under the MIT License. using System; -using System.Net; using System.Net.Http; -using System.Threading.Tasks; using Azure.Core.Pipeline; using Azure.Identity; using Azure.Security.KeyVault.Secrets; @@ -71,24 +69,6 @@ public void SettingHttpClient() #endregion } - [Test] - public void HttpClientProxyConfiguration() - { - #region Snippet:HttpClientProxyConfiguration - - using HttpClientHandler handler = new HttpClientHandler() - { - Proxy = new WebProxy(new Uri("http://example.com")) - }; - - SecretClientOptions options = new SecretClientOptions - { - Transport = new HttpClientTransport(handler) - }; - - #endregion - } - [Test] public void SetPollyRetryPolicy() {