2016-06-29 13 views
6

Service Fabric uygulamasını, powershell ile Azure'a yayımlamaya çalışıyorum. Küme bağlanmak ve komut dosyası "Deploy-FabricApplication.ps1" (Visual Studio'da yeni bir proje oluşturulduğunda oluşturulan bir tane) komutunu çağırmak istiyorum.Hizmet Kumaşını powershell'den dağıtın. Hata -> Get-ServiceFabricClusterManifest: Küme bağlantı örneği boş

Bunu yapmak için yeni komut dosyası oluşturdum. Küme ve sonra aynı komut dosyası ile "Deploy-FabricApplication.ps1" diyoruz.

benim programı başlattıktan sonra aşağıdaki hatayı alıyorum: Bağlantı komut ve Dağıtma-FabricApplication.ps1 ben "Test-ServiceFabricClusterConnection" arıyorum ve her iki komut her iki komut da true verir yılında

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 

Ben "Get-ServiceFabricClusterManifest" çağırıyorum ve her iki durumda da bana bildirir, ancak "Publish-UpgradedServiceFabricApplication.ps1" için "Test-ServiceFabricClusterConnection" eklediğimde, o zaman befor gibi aynı hata döndürdü, ancak "Test-ServiceFabricClusterConnection " aramak. bağlantı komut dosyası için

Kodu:

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 

Özetlemek gerekirse, yardım

Teşekkür küme ve sonra dağıtın-FabricApplication.ps1 kullanmak için bağlantı kurmak için nasıl hiçbir fikrim yok

cevap

11

Connect-ServiceFabricCluster numaralı telefonu ararken yerel bir $clusterConnection değişkeni ayarlanmıştır. SDK komut dosyalarından bazıları, bu değişkenin ayarlanmasını bekler, ancak komut dosyanızı farklı bir kapsamda çalıştırdığınız için, bu yerel değişken bunlara uygun değildir. Ben yardım için

$global:clusterConnection = $clusterConnection 
+0

sayesinde değişken lokal $ clusterConnection içeren clusterConnection değişkeni:

Ya nokta kaynak çağrı

. .\Deploy-FabricApplication.ps1 -PublishProfileFile $PublishProfileFile -ApplicationPackagePath $ApplicationPackagePath -OverrideUpgradeBehavior $OverrideUpgradeBehavior -OverwriteBehavior $OverwriteBehavior -DeployOnly:$DeployOnly -UnregisterUnusedApplicationVersionsAfterUpgrade:$UnregisterUnusedApplicationVersionsAfterUpgrade -UseExistingClusterConnection:$true -SkipPackageValidation:$SkipPackageValidation 

-FabricApplication.ps1 dağıtma veya $ küresel oluşturmak için olabilir Yerel değişkeni global olarak atadı ve şimdi çalışıyor – TomaszMaryniak

+0

Yerel kümenizi sıfırlarsanız ve bağlantıyı yeniden kullanmayı denediğinizde "Hata: ... Özel Durum: Nesne kapalıdır. -> HRESULT özel durum: 0x80071BFE'. Yeni bir powershell penceresi başlatmak onu düzeltir. –

+0

Sıfırlamadan sonra 'Connect-ServiceFabricCluster' çalıştırılıyor:' Connect-ServiceFabricCluster: Nesne kapalı. Satırda: 1 char: 1 + Connect-ServiceFabricCluster + CategoryInfo: InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricObjectClosedException + FullyQualifiedErrorId: TestClusterConnectionErrorId, Microsoft.ServiceFabric.Powershell.ConnectCluster ' –

İlgili konular