【Azure Fabric Service】Service Fabric 托管群集通过 Connect ServiceFabricCluster 连接时候报错 CertificatedNotMatched - LuBu0505/My-Code GitHub Wiki

问题描述

Service Fabric 托管群集, 使用Key Vault中证书,把证书导入到本地安装后,使用该证书的 Thumbprint 作为指令 Connect-ServiceFabricCluster  的 ServerCertThumbprint 和FindValue 的值。结果连接失败,错误消息为:

Connect-ServiceFabricCluster FABRIC_E_SERVER_AUTHENTICATION_FAILED: CertificateNotMatched image

问题解答

根据错误消息来看,就是使用的证书不对导致的。 而根据错误提示 FABRIC_E_SERVER_AUTHENTICATION_FAILED,  判断是 Connect-ServiceFabricCluster  中 ServerCertThumbprint 值错误。因为在自建的Service Fabric集群环境中, ServerCertThumbprint 和 FindValue (ClientCertThumbprint) 使用的同样的证书,所以他们值一样。

而Service Fabric 托管群集则不一样,Server Cert Thumbprint 需要通过 Get-AzResource 在集群的资源属性中获取。 托管集群将自动管理证书,并且在证书过期前的90天内自动更新。

  1. 使用以下命令来查询群集资源,以获取群集证书指纹 ServerCertThumbprint  
$serverThumbprint = (Get-AzResource -ResourceId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ServiceFabric/managedclusters/mysfcluster)
.Properties.clusterCertificateThumbprints
  1. 获取到 serverThumbprint后,使用下面的命令就可以连接到Service Fabric托管集群
##服务端证书指纹
$serverThumbprint = (Get-AzResource -ResourceId 'SF Resource ID' ).Properties.clusterCertificateThumbprints 

##客户端证书指纹 $clientThumbprint= "XXXXXXXXXXXXXXXXXXXXXXXXXXX" 
$connectionEndpoint = "<your sf name>.chinaeast2.cloudapp.chinacloudapi.cn:19000" ##连接到SF托管集群
Connect-ServiceFabricCluster -ConnectionEndpoint $connectionEndpoint -KeepAliveIntervalInSec 10 `
 -X509Credential `
 -ServerCertThumbprint $serverThumbprint `
 -FindType FindByThumbprint `
 -FindValue $clientThumbprint `
 -StoreLocation CurrentUser `
 -StoreName My 

引用文档: https://learn.microsoft.com/zh-cn/azure/service-fabric/how-to-managed-cluster-connect#using-the-service-fabric-powershell-module

  1. 连接成功! image

参考资料

连接到 Service Fabric 托管群集 : https://learn.microsoft.com/zh-cn/azure/service-fabric/how-to-managed-cluster-connect#using-the-service-fabric-powershell-module

Cluster certificate management and 90 day autorotation : https://learn.microsoft.com/en-us/azure/service-fabric/overview-managed-cluster#service-fabric-managed-cluster-advantages

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

分类: 【Azure Fabric Service】

标签: Connect-ServiceFabricClusterService FabricService Fabric托管集群CertificatedNotMatchedProperties clusterCertificateThumbprintsGet-AzResource