Udostępnij przez


Tutorial: Deploy an app to a Service Fabric managed cluster

W tej serii samouczków omówimy następujące zagadnienia:

W tej części serii omówiono następujące zagadnienia:

  • Connect to your Service Fabric managed cluster
  • Upload an application to a cluster
  • Instantiate an application in a cluster
  • Remove an application from a cluster

Wymagania wstępne

Nawiązywanie połączenia z klastrem

To connect to your cluster, you'll need the cluster certificate thumbprint. Tę wartość można znaleźć w danych wyjściowych właściwości klastra wdrożenia zasobu lub wysyłając zapytanie do właściwości klastra w istniejącym zasobie.

The following command can be used to query your cluster resource for the cluster certificate thumbprint.

$serverThumbprint = (Get-AzResource -ResourceId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ServiceFabric/managedclusters/mysfcluster).Properties.clusterCertificateThumbprints

Za pomocą odcisku palca certyfikatu klastra możesz nawiązać połączenie z klastrem.

$connectionEndpoint = "mysfcluster.eastus2.cloudapp.azure.com:19000"
Connect-ServiceFabricCluster -ConnectionEndpoint $connectionEndpoint -KeepAliveIntervalInSec 10 `
      -X509Credential `
      -ServerCertThumbprint $serverThumbprint  `
      -FindType FindByThumbprint `
      -FindValue $clientThumbprint `
      -StoreLocation CurrentUser `
      -StoreName My

Upload an application package

In this tutorial, we will be using the Service Fabric Voting Application sample. For more details on Service Fabric application deployment through PowerShell see Service Fabric deploy and remove applications.

Uwaga

In the Service Fabric managed cluster preview you will not be able to publish applications directly from Visual Studio.

You will first need to package the application for deployment. For this tutorial, please follow the steps for packaging an application from within Visual Studio. It is important to take note of the path where the application has been packaged as it will be used for the path below.

Once the application package has been created you can upload the application package to your cluster. Update the $path value to represent the path where your application package exists, and run the following:

$path = "C:\Users\<user>\Documents\service-fabric-dotnet-quickstart\Voting\pkg\Debug"
Copy-ServiceFabricApplicationPackage -ApplicationPackagePath $path -CompressPackage
Register-ServiceFabricApplicationType -ApplicationPathInImageStore Debug

Tworzenie aplikacji

You can instantiate an application from any application type version that has been registered successfully by using the New-ServiceFabricApplication cmdlet. The name of each application must start with the "fabric:" scheme and must be unique for each application instance. Tworzone są również wszystkie usługi domyślne zdefiniowane w manifeście aplikacji docelowej.

New-ServiceFabricApplication fabric:/Voting VotingType 1.0.0

Once this operation completes, you should see your application instances running in the Service Fabric Explorer.

Usuwanie aplikacji

When an application instance is no longer needed, you can permanently remove it by name using the Remove-ServiceFabricApplication cmdlet, which also automatically removes all services that belong to the application, permanently removing all service state.

Remove-ServiceFabricApplication fabric:/Voting

Następne kroki

In this step, we deployed an application to a Service Fabric managed cluster. To learn more about application deployment options, see:

To learn more about managed cluster configuration options, see: