--- title: "同时设置了 endpoint_suffix 和 primary endpoint - 如何解决此 Elasticsearch 异常" date: 2026-01-30 lastmod: 2026-01-30 description: "Both an endpoint suffix as well as a primary endpoint were set 表示 Azure 客户端配置里同时给了 endpoint_suffix 和 primary endpoint,本文说明该冲突的原因与修复方法。" tags: ["Azure repository", "endpoint_suffix", "primary endpoint", "SettingsException"] summary: "适用版本: 8.8-8.9 1. 错误异常的基本描述 # Both an endpoint suffix as well as a primary endpoint were set 表示 Elasticsearch 在构造 Azure 存储连接串时,发现你同时配置了 endpoint_suffix 和 primary endpoint。这两种方式都可以决定主服务地址,但语义重叠,因此实现明确禁止同时存在。 常见现象 # Azure 仓库或相关客户端初始化失败。 日志中直接出现 SettingsException,而不是后续网络连接超时。 常见于从标准公有云切到自定义 endpoint 时,旧参数未清理干净。 典型报错与异常栈 # SettingsException: Both an endpoint suffix as well as a primary endpoint were set 2. 为什么会发生这个错误 # 源码会先判断 endpoint_suffix、endpoint、secondary_endpoint 三个值是否存在。只要 endpoint_suffix 和 endpoint 同时非空,就直接抛出该异常。 其根因是: endpoint_suffix 适合通过账号名自动推导标准 endpoint。 primary endpoint 适合显式指定完整主 endpoint。 两者并存时,系统无法确定应以哪种方式生成连接串。" --- > **适用版本:** 8.8-8.9 ## 1. 错误异常的基本描述 `Both an endpoint suffix as well as a primary endpoint were set` 表示 Elasticsearch 在构造 Azure 存储连接串时,发现你同时配置了 `endpoint_suffix` 和 `primary endpoint`。这两种方式都可以决定主服务地址,但语义重叠,因此实现明确禁止同时存在。 ### 常见现象 - Azure 仓库或相关客户端初始化失败。 - 日志中直接出现 `SettingsException`,而不是后续网络连接超时。 - 常见于从标准公有云切到自定义 endpoint 时,旧参数未清理干净。 ### 典型报错与异常栈 ```text SettingsException: Both an endpoint suffix as well as a primary endpoint were set ``` ## 2. 为什么会发生这个错误 源码会先判断 `endpoint_suffix`、`endpoint`、`secondary_endpoint` 三个值是否存在。只要 `endpoint_suffix` 和 `endpoint` 同时非空,就直接抛出该异常。 其根因是: - `endpoint_suffix` 适合通过账号名自动推导标准 endpoint。 - `primary endpoint` 适合显式指定完整主 endpoint。 两者并存时,系统无法确定应以哪种方式生成连接串。 ## 3. 如何排查和解决这个异常和解决这个异常 1. 检查 `elasticsearch.yml`、keystore 或环境变量中的 Azure client 配置。 2. 确认同一个 client 下是否同时存在 `endpoint_suffix` 与 `endpoint`。 3. 使用标准 Azure 云环境时通常保留 `endpoint_suffix`。 4. 使用私有云或自定义服务地址时通常删除 `endpoint_suffix`,仅保留 `endpoint`。 ### 排查时需要注意的问题 - 不同 client 名称下的配置不要混看。 - 参数若来自多处叠加,要核对最终生效值。 - 清理这个冲突后,还应检查 secondary endpoint 是否也有冲突。 ## 4. 如何解决这个错误 ### 常用修复思路 - 二选一保留 `endpoint_suffix` 或 `primary endpoint`。 - 标准云环境用 `endpoint_suffix`,自定义服务地址用显式 `endpoint`。 - 清理迁移时遗留的旧参数。 ### 后续注意事项与推荐建议 - 为 Azure client 配置建立互斥校验。 - 将标准云和私有云模板分开维护。 ### 借助 INFINI 产品提升排障效率 - [INFINI Console](https://docs.infinilabs.com/console/main/) 可用于对比多集群 Azure 仓库配置差异。 - [INFINI Gateway](https://docs.infinilabs.com/gateway/main/) 适合记录配置变更调用,追踪冲突参数来源。 ## 5. 小结 `Both an endpoint suffix as well as a primary endpoint were set` 的根因是 Azure 主 endpoint 的两种定义方式同时生效。把配置收敛为单一路径即可解决。 ## 相关错误 - [同时设置了 endpoint_suffix 和 secondary endpoint](/knowledge-base/elasticsearch_error/both-an-endpoint-suffix-as-well-as-a-secondary-endpoint-were-set-how-to-solve-this-elasticsearch-exception/) - [设置 secondary endpoint 时必须提供 primary endpoint](/knowledge-base/elasticsearch_error/a-primary-endpoint-is-required-when-setting-a-secondary-endpoint-how-to-solve-this-elasticsearch-exception/) - [没有默认 Azure data store 配置](/knowledge-base/elasticsearch_error/no-default-azure-data-store-configured-how-to-solve-this-elasticsearch-exception/) - [多个默认 Azure data store 配置](/knowledge-base/elasticsearch_error/multiple-default-azure-data-stores-configured-how-to-solve-this-elasticsearch-exception/) ## 附:日志上下文 ```java final boolean hasEndpointSuffix = Strings.hasText(endpointSuffix); final boolean hasEndpoint = Strings.hasText(endpoint); final boolean hasSecondaryEndpoint = Strings.hasText(secondaryEndpoint); if (hasEndpointSuffix && hasEndpoint) { throw new SettingsException("Both an endpoint suffix as well as a primary endpoint were set"); } if (hasEndpointSuffix && hasSecondaryEndpoint) { throw new SettingsException("Both an endpoint suffix as well as a secondary endpoint were set"); } ```