检查 Tables 构建器是否接收完整的 HTTP 管道。该输入会覆盖其单独的 httpClient 选项;如果应用程序拥有管道,请在构建该管道时配置支持代理的传输。

对于直接传入 Netty HTTP 客户端的方式,请构建传输并将其传递给 Tables:

ProxyOptions proxy = new ProxyOptions(
    ProxyOptions.Type.HTTP,
    new InetSocketAddress("proxy.example.net", 8080)
);
proxy.setCredentials(proxyUser, proxyPassword);

HttpClient transport = new NettyAsyncHttpClientBuilder()
    .proxy(proxy)
    .build();

TableClient tables = new TableClientBuilder()
    .connectionString(storageConnectionString)
    .tableName("records")
    .httpClient(transport)
    .buildClient();

此处的 HttpClient 是 com.azure.core.http.HttpClient。其他类型来自 Azure Core HTTP/Netty、Azure Data Tables 和 java.net.InetSocketAddress。配置和凭据变量由应用程序提供。

ProxyOptions.Type.HTTP 选择中间层;setCredentials 提供其账户,对于无需身份验证的终结点可以省略。在该配置中,HTTP 代理列表中的条目可以为允许的公共 Tables 终结点路由提供地址;不要在传输上留下代理凭据。存储连接字符串仍然选择 Tables 服务。

这使用连接字符串身份验证。身份凭据方案可以有一个单独用于获取令牌的 HTTP 客户端,其路由也需要配置。

相关文章