Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This sample Service Fabric SDK PowerShell script deletes a running Service Fabric application instance and unregisters an application type and version from the cluster. Deleting the application instance also deletes all the running service instances associated with that application. Customize the parameters as needed.
If needed, install the Service Fabric PowerShell module with the Service Fabric SDK.
Sample script
# Variables
$endpoint = 'mysftestcluster.chinaeast.cloudapp.chinacloudapi.cn:19000'
$thumbprint = '2779F0BB9A969FB88E04915FFE7955D0389DA7AF'
$packagepath="C:\Users\sfuser\Documents\Visual Studio 2017\Projects\MyApplication\MyApplication\pkg\Release"
# Connect to the cluster using a client certificate.
Connect-ServiceFabricCluster -ConnectionEndpoint $endpoint `
-KeepAliveIntervalInSec 10 `
-X509Credential -ServerCertThumbprint $thumbprint `
-FindType FindByThumbprint -FindValue $thumbprint `
-StoreLocation CurrentUser -StoreName My
# Remove an application instance
Remove-ServiceFabricApplication -ApplicationName fabric:/MyApplication
# Unregister the application type
Unregister-ServiceFabricApplicationType -ApplicationTypeName MyApplicationType -ApplicationTypeVersion 1.0.0
Script explanation
This script uses the following commands. Each command in the table links to command specific documentation.
| Command | Notes |
|---|---|
| Remove-ServiceFabricApplication | Removes a running Service Fabric application instance from the cluster. |
| Unregister-ServiceFabricApplicationType | Unregisters a Service Fabric application type and version from the cluster. |
Next steps
For more information on the Service Fabric SDK PowerShell module, see SDK PowerShell documentation.
For more information on the Service Fabric Azure PowerShell module, see Azure PowerShell documentation.
Additional PowerShell samples for Service Fabric can be found in the PowerShell samples.