Stringfellow
Stringfellow

Reputation: 2908

How to Get Visual Studio to Publish an Application to Service Fabric Cluster Secured by Certificate Common Name Instead of Thumbprint?

I followed the steps documented here to convert my existing ARM template to use the commonname setting instead of thumbprint. The deployment was successful and I was able to connect to the Service Fabric Explorer using my browser after the typical certificate selection popup. Next, I tried to deploy an application to the cluster just like I had been previously. Even though I can see the cluster connection endpoint URI in the VS public service fabric application dialog, VS fails to connect to the cluster. Before, I would get a prompt to permit VS to access the local certificate. Does anyone know how to get VS to deploy an application to a service fabric cluster setup using the certificate common name?

Extracts from the MS link above:

"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"
        }
      },

and

{
    "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')]"
    },
    ...

Upvotes: 1

Views: 771

Answers (1)

Stringfellow
Stringfellow

Reputation: 2908

I found the solution for Visual Studio. I needed to add/update to the PublishProfiles/Cloud.xml file. I replaced ServerCertThumbprint with ServerCommonName, and then used the certificate CN for the new property and the existing FindValue property. Additionally, I changed the property for FindType to FindBySubjectName. I am now able to successfully connect and publish my application to the cluster.

<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

Upvotes: 2

Related Questions