使用 Azure 自动化连接到 ServiceFabric

Connect to ServiceFabric using Azure Automation

我正在尝试通过 Azure 自动化使用混合 运行book worker 运行 以下测试脚本:

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

当我 运行 在我的机器上本地运行这个脚本时,它可以工作。当我 运行 这个脚本在 VM 上使用 Powershell 会话时,它也能正常工作。

当我将此脚本放入 运行book 中,然后通过混合工作组 运行 运行book 时(它指向同一个 VM,因为只有一个工作人员注册到该组),我得到一个错误:

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

我需要配置什么才能使混合组可以执行本地 Powershell 会话已经可以正确执行的相同脚本?


一些额外信息:

您使用的证书位置基于运行脚本的用户 (-StoreLocation CurrentUser -StoreName My)。

您应该使用运行自动化的(/任何)帐户可以访问的位置。

Azure Automation 使用 Get-AzAutomationCertificate 命令对此提供 built-in 支持。

更多信息here