Search code examples
powershellazure-service-fabric

Deploy app to service fabric with PowerShell


I have service fabric up and running in Azure. Also I have Visual Studio solution with two projects: Service Fabric and Web Service. I would like to deploy the service to the service fabric in azure. When I right-click my service fabric project and click "Publish", the service smoothly deploys to the cloud fabric. I would like to do the same with PowerShell.

It seems I need to run this script:

# 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

# Copy the application package to the cluster image store.
Copy-ServiceFabricApplicationPackage $packagepath -ImageStoreConnectionString fabric:ImageStore -ApplicationPackagePathInImageStore $packagename

# Register the application type.
Register-ServiceFabricApplicationType -ApplicationPathInImageStore $packagename

# Create the service instance.
$appName = <name that I see in fabric explorer under 'typeName' in azure>
New-ServiceFabricService -ApplicationName fabric:/$appName -ServiceName fabric:/$appName/MyApp -ServiceTypeName $serviceTypeName -Stateless -PartitionSchemeSingleton -InstanceCount -1

Prior to running the script I right click my fabric app and select "Package".

The very last command of my script fails with "application not found"

What can be missing?


Solution

  • The problem was that I used wrong ApplicationName and ServiceName in the command New-ServiceFabricService.

    In order to find out what correct values are, I ran Get-ServiceFabricApplication and Get-ServiceFabricService.

    These pages were very helpful for building troubleshooting the scripts: