I am trying to run the following test script using a hybrid runbook worker via Azure Automation:
Connect-ServiceFabricCluster -ConnectionEndpoint "the-service-fabric-azure-url" -FindType FindByThumbprint -FindValue "the-thumbprint" -X509Credential -ServerCertThumbprint "the-thumbprint" -StoreLocation CurrentUser -StoreName My -Verbose
$app = Get-ServiceFabricApplication -ApplicationName "fabric:/the-application-name"
Write-Output $app
When I run this script locally on my machine, it works. When I run this script using a Powershell session on the VM, it also works.
When I put this script in a runbook and then run the runbook via the hybrid work group (which points to the same VM, since there is only one worker registered to that group), I get an error:
Connect-ServiceFabricCluster : An error occurred during this operation. Please check the trace logs for more details. At line:1 char:1 +
Connect-ServiceFabricCluster -ConnectionEndpoint "my-service-fabric-url... +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
CategoryInfo : InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricException +
FullyQualifiedErrorId : CreateClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.ConnectCluster
What do I need to configure so that the hybrid group can execute the same script that a local Powershell session can already execute correctly?
Some extra information:
You're using a certificate location that's based on the user that runs the script (-StoreLocation CurrentUser -StoreName My
).
You should use a location that can be accessed by (the / any) account that runs the automation instead.
Azure Automation has built-in support for this, using the Get-AzAutomationCertificate
command.
More info here.