【Azure 微服务】PowerShell中,用Connect-ServiceFabricCluster命令无法连接到sf-test.chinaeast2.cloudapp.chinacloudapi.cn:19000 问题分析
问题描述
Azure Service Fabric提供了PowerShell的指令来进行创建,管理资源,如Get-ServiceFabricClusterHealth 获取当前集群的健康状态,但这些命令都需要使用Connect-ServiceFabricCluster 先连接到集群。而在使用连接命令时候,始终连接不成功。本且是运行PowerShell命令的机器上已经安装了SF的主要证书。通过添加 -debug命令查看输出结果,不能连接成功的原因为认证失败。[System.Fabric.FabricServerAuthenticationFailedException: FABRIC_E_SERVER_AUTHENTICATION_FAILED: 0x800b0109]
解决办法
在Service Fabric证书页面中,发现有安装主要证书,和次要证书,当主要证书认证失败时,尝试通过次要证书连接SF集群。发现通过次要证书成功连接。
根据次要证书可以登录成功,主要证书确不可以的情况,进一步的调研和测试,得出Azure Service Fabrics SDK 的默认证书加载行为是部署和使用过期日期最远的已定义证书,而不管其主要或次要配置定义如何。以下的测试为两个证书到期时间一样,使用PowerShell连接的时候也是会选择次要证书进行连接。如果需要让Service Fabrics使用主要证书,则可以在创建证书的时候,让主要证书的过期时间长一些。
主次证书信息(注意:过期时间一样)
主要证书连接失败
次要证书连接成功
附录一: 错误消息
警告: Failed to contact Failover Manager Service, Attempting to contact FMM... False 详细信息: System.Fabric.FabricServerAuthenticationFailedException: FABRIC_E_SERVER_AUTHENTICATION_FAILED: 0x800b0109 ---> System.Runtime.InteropServices.COMException: 异常来自 HRESULT:0x80071C44 在 System.Fabric.Interop.NativeClient.IFabricQueryClient11.EndGetPartitionList2(IFabricAsyncOperationContext context) 在 System.Fabric.FabricClient.QueryClient.GetPartitionListAsyncEndWrapper(IFabricAsyncOperationContext context) 在 System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously) --- 内部异常堆栈跟踪的结尾 ---
附录二:Connect-ServiceFabricCluster完整命令
Connect-ServiceFabricCluster -ConnectionEndpoint 'sf-test.chinaeast2.cloudapp.chinacloudapi.cn:19000' ` >> -KeepAliveIntervalInSec 10 ` >> -X509Credential -ServerCertThumbprint 'your thumbprint' ` >> -FindType FindByThumbprint -FindValue 'your thumbprint' ` >> -StoreLocation CurrentUser -StoreName My -debug
参考资料
The Connect-ServiceFabricCluster cmdlet creates a connection to a Service Fabric cluster that allows you to run management actions for that cluster. After you connect to a cluster, you can view the settings of the connection by using the Get-ServiceFabricClusterConnection cmdlet.
To manage Service Fabric clusters, start Windows PowerShell by using the Run as administrator option.
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?