适用版本: 6.8-8.9
1. 错误异常的基本描述 #
这条异常表示 Azure 仓库客户端的认证方式配置冲突。源码要求 secret key 和 shared access token 二选一,若两者同时存在,就会抛出 SettingsException。
常见现象 #
- Azure 仓库在初始化时失败。
- 看起来认证信息“都配了”,但实际因为冲突无法使用。
- 常见于环境变量和 keystore 同时注入了两种凭据。
典型报错与异常栈 #
SettingsException: Both a secret as well as a shared access token were set.
2. 为什么会发生这个错误 #
Azure 客户端需要明确采用一种认证方式。若同时提供 access key 和 SAS token,Elasticsearch 不会猜测优先级,而是直接拒绝。常见原因包括:
- 新旧认证方案切换时没有清理旧配置。
- 多套环境变量同时生效。
- 模板和 keystore 各自注入了一套凭据。
3. 如何排查和解决这个异常和解决这个异常 #
- 检查 Azure client 的全部认证相关配置。
- 确认
secret key和sas token是否同时存在。 - 按实际策略只保留一种认证方式。
- 若使用 SAS token,确认 secret key 已被彻底移除。
- 修复后重新验证仓库。
4. 如何解决这个错误 #
常用修复思路 #
- 在 secret key 和 SAS token 中二选一。
- 清理历史遗留凭据,避免双重注入。
- 对凭据来源做统一管理。
后续注意事项与推荐建议 #
- 凭据切换时应有显式迁移步骤。
- 建议在配置发布前校验“认证方式互斥”。
借助 INFINI 产品提升排障效率 #
- INFINI Console 可定位配置变更窗口。
- INFINI Gateway 可帮助追踪异常引入时点。
5. 小结 #
Both a secret as well as a shared access token were set 的根因是两套认证方式同时生效。清理为单一认证方式即可。
相关错误 #
- neither-a-secret-key-nor-a-shared-access-token-was-set-how-to-solve-this-elasticsearch-exception
- invalid-azure-client-settings-with-name-clientname-how-to-solve-this-elasticsearch-exception
- if-you-want-to-use-an-azure-repository-you-need-to-define-a-client-configuration-how-to-solve-this-elasticsearch-exception
附:日志上下文 #
if (hasSasToken && hasKey) {
throw new SettingsException("Both a secret as well as a shared access token were set.");
}





