如何使Visual Studio将应用程序发布到通过证书公用名而不是指纹保护的Service Fabric群集?

时间:2018-10-02 17:45:16

标签: visual-studio certificate azure-service-fabric

我按照here中记录的步骤将现有的ARM模板转换为使用commonname设置而不是指纹。部署成功,并且在典型的证书选择弹出窗口之后,我能够使用浏览器连接到Service Fabric资源管理器。接下来,我尝试像以前一样将应用程序部署到集群。即使在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')]"
    },
    ...

1 个答案:

答案 0 :(得分:1)

我找到了Visual Studio的解决方案。我需要添加/更新到PublishProfiles/Cloud.xml文件。我将ServerCertThumbprint替换为ServerCommonName,然后将证书CN用于新属性和现有FindValue属性。另外,我将FindType的属性更改为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" />

image