首页 > 解决方案 > 如何让 Visual Studio 将应用程序发布到由证书公用名而不是指纹保护的 Service Fabric 群集?

问题描述

我按照此处记录的步骤将现有的 ARM 模板转换为使用公用名设置而不是指纹。部署成功,在典型的证书选择弹出窗口后,我能够使用浏览器连接到 Service Fabric Explorer。接下来,我尝试像以前一样将应用程序部署到集群中。即使我可以在 VS 公共服务结构应用程序对话框中看到集群连接端点 URI,VS 也无法连接到集群。之前,我会得到一个提示,允许 VS 访问本地证书。有谁知道如何让 VS 使用证书公用名将应用程序部署到服务结构集群设置?

从上面的 MS 链接中提取:

"virtualMachineProfile": {
  "extensionProfile": {
    "extensions": [`enter code here`
      {
        "name": "[concat('ServiceFabricNodeVmExt','_vmNodeType0Name')]",
        "properties": {
          "type": "ServiceFabricNode",
          "autoUpgradeMinorVersion": true,
          "protectedSettings": {
            "StorageAccountKey1": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key1]",
            "StorageAccountKey2": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key2]"
          },
          "publisher": "Microsoft.Azure.ServiceFabric",
          "settings": {
            "clusterEndpoint": "[reference(parameters('clusterName')).clusterEndpoint]",
            "nodeTypeRef": "[variables('vmNodeType0Name')]",
            "dataPath": "D:\\SvcFab",
            "durabilityLevel": "Bronze",
            "enableParallelJobs": true,
            "nicPrefixOverride": "[variables('subnet0Prefix')]",
            "certificate": {
              "commonNames": [
                 "[parameters('certificateCommonName')]"
              ],
              "x509StoreName": "[parameters('certificateStoreValue')]"
            }
          },
          "typeHandlerVersion": "1.0"
        }
      },

{
    "apiVersion": "2018-02-01",
    "type": "Microsoft.ServiceFabric/clusters",
    "name": "[parameters('clusterName')]",
    "location": "[parameters('clusterLocation')]",
    "dependsOn": [
    "[concat('Microsoft.Storage/storageAccounts/', variables('supportLogStorageAccountName'))]"
    ],
    "properties": {
    "addonFeatures": [
        "DnsService",
        "RepairManager"
    ],        
    "certificateCommonNames": {
        "commonNames": [
        {
            "certificateCommonName": "[parameters('certificateCommonName')]",
            "certificateIssuerThumbprint": ""
        }
        ],
        "x509StoreName": "[parameters('certificateStoreValue')]"
    },
    ...

标签: visual-studiocertificateazure-service-fabric

解决方案


我找到了 Visual Studio 的解决方案。我需要添加/更新PublishProfiles/Cloud.xml文件。我替换ServerCertThumbprintServerCommonName,然后将证书 CN 用于新属性和现有FindValue属性。此外,我将属性更改为FindTypeto FindBySubjectName。我现在能够成功连接并将我的应用程序发布到集群。

<ClusterConnectionParameters 
    ConnectionEndpoint="sf-commonnametest-scus.southcentralus.cloudapp.azure.com:19000"
    X509Credential="true"
    ServerCommonName="sfrpe2eetest.southcentralus.cloudapp.azure.com"
    FindType="FindBySubjectName"
    FindValue="sfrpe2eetest.southcentralus.cloudapp.azure.com"
    StoreLocation="CurrentUser"
    StoreName="My" />

图片


推荐阅读