Tôi đang cố gắng xuất bản ứng dụng Dịch vụ Vải lên Azure bằng PowerShell. Tôi muốn kết nối với cụm và sau đó gọi tập lệnh "Deploy-FabricApplication.ps1" (được tạo khi dự án mới được tạo trong studio trực quan)Triển khai Dịch vụ Vải từ PowerShell. Lỗi -> Get-ServiceFabricClusterManifest: Trường hợp kết nối cụm là null
Để làm điều đó, tôi đã tạo tệp tập lệnh mới chịu trách nhiệm kết nối với cluster và sau đó từ tập tin kịch bản đó tôi đang gọi là "Deploy-FabricApplication.ps1".
Sau khi tung ra kịch bản của tôi Tôi nhận được lỗi sau:
Get-ServiceFabricClusterManifest : Cluster connection instance is null
At C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:116 char:28
+ $clusterManifestText = Get-ServiceFabricClusterManifest
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-ServiceFabricClusterManifest], NullReferenceException
+ FullyQualifiedErrorId : GetClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.GetClusterManifest
Trong kịch bản kết nối và Triển khai-FabricApplication.ps1 tôi kêu gọi "Test-ServiceFabricClusterConnection" và trong cả hai kịch bản nó sẽ trả về cũng thật trong cả hai kịch bản tôi đang gọi "Get-ServiceFabricClusterManifest" và trong cả hai trường hợp, nó trả lại cho tôi biểu hiện nhưng khi tôi đã thêm "Test-ServiceFabricClusterConnection" vào "Publish-UpgradedServiceFabricApplication.ps1" thì nó đã trả về lỗi tương tự như đã đề cập trước đó nhưng cho "Test-ServiceFabricClusterConnection " gọi điện.
mã để kết nối kịch bản:
Param
(
[String]
$PublishProfileFile,
[String]
$ApplicationPackagePath,
[Switch]
$DeployOnly,
[Boolean]
$UnregisterUnusedApplicationVersionsAfterUpgrade,
[String]
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')]
$OverrideUpgradeBehavior = 'None',
[String]
[ValidateSet('Never','Always','SameAppTypeAndVersion')]
$OverwriteBehavior = 'Never',
[Switch]
$SkipPackageValidation,
[String]
$ConnectionEndpoint,
[String]
$ServerCertThumbprint,
[String]
$FindType,
[String]
$FindValue,
[String]
$StoreLocation,
[String]
$StoreName
)
$connectArgs = @{ ConnectionEndpoint = $ConnectionEndpoint; X509Credential = $True; StoreLocation = $StoreLocation; StoreName = $StoreName; ServerCertThumbprint = $ServerCertThumbprint; FindType = $FindType; FindValue = $FindValue }
try
{
Connect-ServiceFabricCluster @connectArgs;
$connection = Get-ServiceFabricClusterConnection;
Write-Host $connection;
$m = Get-ServiceFabricClusterManifest
Write-Host $m;
}
catch [System.Fabric.FabricObjectClosedException]
{
Write-Warning "Service Fabric cluster may not be connected."
throw
}
.\Deploy-FabricApplication.ps1 -PublishProfileFile $PublishProfileFile -ApplicationPackagePath $ApplicationPackagePath -OverrideUpgradeBehavior $OverrideUpgradeBehavior -OverwriteBehavior $OverwriteBehavior -DeployOnly:$DeployOnly -UnregisterUnusedApplicationVersionsAfterUpgrade:$UnregisterUnusedApplicationVersionsAfterUpgrade -UseExistingClusterConnection:$true -SkipPackageValidation:$SkipPackageValidation
Để tóm tắt, tôi không có ý tưởng làm thế nào để thiết lập kết nối cụm và sau đó sử dụng nó trong Triển khai-FabricApplication.ps1
Nhờ sự giúp đỡ
Nhờ sự giúp đỡ, tôi đã gán biến cục bộ cho toàn cầu và có vẻ như bây giờ nó hoạt động – TomaszMaryniak
Nếu bạn sau đó đặt lại cụm cục bộ của bạn, và thử và tái sử dụng kết nối bạn nhận được 'Lỗi: ... Ngoại lệ: Đối tượng được đóng. -> Ngoại lệ từ HRESULT: 0x80071BFE'. Bắt đầu một cửa sổ PowerShell mới sửa chữa nó. –
Và chạy 'Connect-ServiceFabricCluster' sau khi thiết lập lại được bạn:' Connect-ServiceFabricCluster: Đối tượng được đóng lại. Tại dòng: 1 char: 1 + Connect-ServiceFabricCluster + CategoryInfo: InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricObjectClosedException + FullyQualifiedErrorId: TestClusterConnectionErrorId, Microsoft.ServiceFabric.Powershell.ConnectCluster' –