Cuir in eagar

Comhroinn trí


Tutorial: Deploy an app to a Service Fabric managed cluster

In this tutorial series we will discuss:

This part of the series covers how to:

  • 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

Prerequisites

Connect to your cluster

To connect to your cluster, you'll need the cluster certificate thumbprint. You can find this value in the cluster properties output of your resource deployment or by querying the cluster properties on an existing resource.

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

With the cluster certificate thumbprint, you're ready to connect to your cluster.

$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.

Note

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

Create an application

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. Any default services defined in the application manifest of the target application type are also created.

New-ServiceFabricApplication fabric:/Voting VotingType 1.0.0

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

Remove an application

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

Next steps

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: