Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQ] Enable Multi-Proxy Support in Track 2 Azure.Core #5372

Closed
joshfree opened this issue Sep 13, 2019 · 12 comments
Closed

[FEATURE REQ] Enable Multi-Proxy Support in Track 2 Azure.Core #5372

joshfree opened this issue Sep 13, 2019 · 12 comments
Assignees
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. Docs feature-request This issue requires a new behavior in the product in order be resolved.
Milestone

Comments

@joshfree
Copy link
Member

joshfree commented Sep 13, 2019

Is your feature request related to a problem? Please describe.
Some customers expect to run in an environment with a global proxy setting. Our Track 2 SDKs should be able to have a proxy setting independent of that and not overwrite the global setting.

Describe the solution you'd like
The ability to have multi-proxy support so that no connection can overwrite the proxy settings for another connection.

Additional context
This is a feature request we should investigate for Preview 4

@joshfree joshfree added Client This issue points to a problem in the data-plane of the library. Azure.Core azure-core feature-request This issue requires a new behavior in the product in order be resolved. labels Sep 13, 2019
@alzimmermsft alzimmermsft self-assigned this Sep 13, 2019
@alzimmermsft
Copy link
Member

PR #5387 adds documentation and samples on how to configure a proxy for both HttpClient implementations that we have plugin packages for, does this help resolve the multi-proxy support issue?

@joshfree joshfree added the Docs label Sep 19, 2019
@joshfree
Copy link
Member Author

@alzimmermsft It's a good start, but we need an example of 2 unrelated sdks in a sample application using 2 different authenticated proxies (digest and basic authenticated proxy).

/cc @amishra-dev

@conniey
Copy link
Member

conniey commented Oct 2, 2019

This is an ask from one of our customers too, who don't want a global proxy configuration. Track 1 Event Hubs has the concept of a ProxyConfiguration that people can pass when creating the client. This also exists in Track 2 Event Hubs.

@joshfree joshfree assigned jianghaolu and unassigned alzimmermsft Oct 7, 2019
@joshfree
Copy link
Member Author

joshfree commented Oct 7, 2019

@jianghaolu can you please prioritize this for the November preview release?

@jianghaolu
Copy link
Contributor

Maybe I'm missing something here but why not just create another HttpClient with a different proxy setup?

@conniey
Copy link
Member

conniey commented Oct 8, 2019

This may already be supported in Track 2, just have to ensure it works. In Track 1 storage libraries, they use HttpURLConnection, which only supports the global proxy configuration.

@joshfree
Copy link
Member Author

Just following up here -- we should create a quick sample showing Digest and Basic Authenticated Proxy working on Track 2. If there are any feature gaps in Azure.Core around Digest then we should open up additional tracking items to complete this work in an upcoming monthly SDK update.

@amishra-dev
Copy link

@joshfree, samples is a good idea (just showing how to do 2 pipelines with 2 proxies). And as long as we can confirm internally that it works and we can integrate this with eventhub, I think we are good.

@jianghaolu
Copy link
Contributor

jianghaolu commented Oct 30, 2019

this is a simple example of talking to Key vault and Storage using different proxies:

public class Main {
    private static final ProxyOptions proxy1 = new ProxyOptions(ProxyOptions.Type.HTTP,
            new InetSocketAddress("10.127.70.25", 8085))
        .setCredentials("azureuser", "StrongPass!123");

    private static final ProxyOptions proxy2 = new ProxyOptions(ProxyOptions.Type.HTTP,
            new InetSocketAddress("10.127.70.25", 8888));

    public static void main(String... args) throws Exception {
        InteractiveBrowserCredential credential1 = new InteractiveBrowserCredentialBuilder()
                .clientId("<client id>")
                .port(8765)
                .build();

        InteractiveBrowserCredential credential2 = new InteractiveBrowserCredentialBuilder()
                .clientId("<client id>")
                .port(8765)
                .proxyOptions(proxy2)
                .build();

        NioEventLoopGroup sharedElg = new NioEventLoopGroup();

        HttpClient client1 = new NettyAsyncHttpClientBuilder()
                .proxy(proxy1)
                .nioEventLoopGroup(sharedElg)
                .build();

        HttpClient client2 = new NettyAsyncHttpClientBuilder()
                .proxy(proxy2)
                .nioEventLoopGroup(sharedElg)
                .build();

        SecretClient secretClient = new SecretClientBuilder()
                .httpClient(client1)
                .credential(credential1)
                .vaultUrl("https://{vault name}.vault.azure.net")
                .buildClient();

        KeyVaultSecret secret = secretClient.getSecret("the-secret");
        System.out.println(secret.getId() + ": " + secret.getValue());

        BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
                .httpClient(client2)
                .credential(credential2)
                .endpoint("https://{storage account}.blob.core.windows.net/")
                .buildClient();

        System.out.println(blobServiceClient.listBlobContainers().stream().count());
    }
}

Note that AAD login does not support proxy authentication yet.

@amishra-dev
Copy link

This is great @jianghaolu. thanks for getting this together. Do you want to put this in a wiki page? or if you want I can do that. Thanks again.

@joshfree
Copy link
Member Author

reassigning this to @alzimmermsft to follow up with wiki documentation as part of closing this issue.

@alzimmermsft
Copy link
Member

Closing as this wiki adds guidelines on how to configure a proxy on HttpClients: https://github.com/Azure/azure-sdk-for-java/wiki/Proxying

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. Docs feature-request This issue requires a new behavior in the product in order be resolved.
Projects
None yet
Development

No branches or pull requests

5 participants