3
votes

I know you can publish a Service Fabric application written in C# using Visual Studio, and I have read this article on using TFS or VSTS to set up continuous integration DevOps builds of a Service Fabric application.

How can I just do this all manually using PowerShell? I know I can do the following using PowerShell from this article on deployment:

  • Use Visual Studio to package the project.
  • Transfer the package to a remote server.
  • Use the PowerShell script examples in the article to deploy the package while I am in the context of the remote server.

Instead, here are two bits I can't seem to figure out which would assist me in doing this from PowerShell:

  • Using PowerShell, how can I package my Service Fabric project the same way you can when you are in the context of Visual Studio?
  • Using PowerShell, how can I remotely deploy my Service Fabric project the same way you can when you are in the context of Visual Studio?
2

2 Answers

2
votes

If you haven't seen this link, take a look at Deploy and Remove Packages using Powershell article.

Suppose you have a folder named MyApplicationType that contains the necessary application manifest, service manifests, and code/config/data packages. The Copy-ServiceFabricApplicationPackage command uploads the package to the cluster Image Store

That takes a directory and uploads it. Then you have to tell it to take that image and use it in the application.

The Register-ServiceFabricApplicationType command returns only after the system has successfully copied the application package. How long this takes depends on the contents of the application package. If needed, the -TimeoutSec parameter can be used to supply a longer timeout.

After you register it you can create the application:

You can instantiate an application by using any application type version that has been registered successfully through the New-ServiceFabricApplication command

2
votes

To generate the package through the command line, you can call the "Package" target on the sfproj file.

See my answer on create a deployment package for Service Fabric that includes all artifacts necessary to run the designed workflows at runtime

Then follow the instructions from https://azure.microsoft.com/en-us/documentation/articles/service-fabric-deploy-remove-applications/ as blackSphere suggested.