Service Fabric Application Deployment task

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

Use this task in a build or release pipeline to deploy a Service Fabric application to a cluster. This task deploys an Azure Service Fabric application to a cluster according to the settings defined in the publish profile.

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, run and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Prerequisites

Service Fabric

This task uses a Service Fabric installation to connect and deploy to a Service Fabric cluster.
Download and install Service Fabric on the build agent.

YAML snippet

# Service Fabric application deployment
# Deploy an Azure Service Fabric application to a cluster
- task: ServiceFabricDeploy@1
  inputs:
    applicationPackagePath: 
    serviceConnectionName: 
    #publishProfilePath: # Optional
    #applicationParameterPath: # Optional
    #overrideApplicationParameter: false # Optional
    #compressPackage: false # Optional
    #copyPackageTimeoutSec: # Optional
    #registerPackageTimeoutSec: # Optional
    #overwriteBehavior: 'SameAppTypeAndVersion' # Options: always, never, sameAppTypeAndVersion
    #skipUpgradeSameTypeAndVersion: false # Optional
    #skipPackageValidation: false # Optional
    #useDiffPackage: false # Optional
    #overridePublishProfileSettings: false # Optional
    #isUpgrade: true # Optional
    #unregisterUnusedVersions: true # Optional
    #upgradeMode: 'Monitored' # Required when overridePublishProfileSettings == True && IsUpgrade == True# Options: monitored, unmonitoredAuto, unmonitoredManual
    #failureAction: 'Rollback' # Required when overridePublishProfileSettings == True && IsUpgrade == True && UpgradeMode == Monitored# Options: rollback, manual
    #upgradeReplicaSetCheckTimeoutSec: # Optional
    #timeoutSec: # Optional
    #forceRestart: false # Optional
    #healthCheckRetryTimeoutSec: # Optional
    #healthCheckWaitDurationSec: # Optional
    #healthCheckStableDurationSec: # Optional
    #upgradeDomainTimeoutSec: # Optional
    #considerWarningAsError: false # Optional
    #defaultServiceTypeHealthPolicy: # Optional
    #maxPercentUnhealthyDeployedApplications: # Optional
    #upgradeTimeoutSec: # Optional
    #serviceTypeHealthPolicyMap: # Optional
    #configureDockerSettings: false # Optional
    #registryCredentials: 'AzureResourceManagerEndpoint' # Required when configureDockerSettings == True# Options: azureResourceManagerEndpoint, containerRegistryEndpoint, usernamePassword
    #dockerRegistryConnection: # Required when configureDockerSettings == True && RegistryCredentials == ContainerRegistryEndpoint
    #azureSubscription: # Required when configureDockerSettings == True && RegistryCredentials == AzureResourceManagerEndpoint
    #registryUserName: # Optional
    #registryPassword: # Optional
    #passwordEncrypted: true # Optional

Task Inputs

ParametersDescription
applicationPackagePath
Application Package
(Required) Path to the application package that is to be deployed. [Variables](https://go.microsoft.com/fwlink/?LinkID=550988) and wildcards can be used in the path
serviceConnectionName
Cluster Service Connection
(Required) Select an Azure Service Fabric service connection to be used to connect to the cluster. The settings defined in this referenced service connection will override those defined in the publish profile. Choose 'Manage' to register a new service connection.
To connect to the cluster, the service fabric task uses the machine cert store to store the information about the certificate. Using the same certificate, if two releases run together on one machine they will start properly. However, if one of the tasks is complete, the certificate from the machine cert store would be cleaned up, which would affect the second release
publishProfilePath
Publish Profile
(Optional) Path to the publish profile file that defines the settings to use. [Variables](https://go.microsoft.com/fwlink/?LinkID=550988) and wildcards can be used in the path. Publish profiles can be created in Visual Studio as shown here
applicationParameterPath
Application Parameters
(Optional) Path to the application parameters file. [Variables](https://go.microsoft.com/fwlink/?LinkID=550988) and wildcards can be used in the path. If specified, this will override the value in the publish profile. Application parameters file can be created in Visual Studio as shown here
overrideApplicationParameter
Override Application Parameters
(Optional) Variables defined in the build or release pipeline will be matched against the 'Parameter Name' entries in the application manifest file. Application parameters file can be created in Visual Studio as shown here
Example: If your application has a parameter defined as below-
<Parameters>
<Parameter Name = "SampleApp_PartitionCount" Value ="1"/>
<Parameter Name = "SampleApp_InstanceCount" DefaultValue ="-1"/>
</Parameters>

and you want to change the partition count to 2, you can define a release pipeline or an environment variable "SampleApp_PartitionCount" and its value as "2".
Note: If same variables are defined in the release pipeline and in the environment, then the environment variables will supersede the release pipeline variables
Default value: false

compressPackage
Compress Package
(Optional) Indicates whether the application package should be compressed before copying to the image store. If enabled, this will override the value in the publish profile. More information for compress package can be found here
Default value: false
copyPackageTimeoutSec
CopyPackageTimeoutSec
(Optional) Timeout in seconds for copying application package to image store. If specified, this will override the value in the publish profile
registerPackageTimeoutSec
RegisterPackageTimeoutSec
(Optional) Timeout in seconds for registering or un-registering application package
overwriteBehavior
Overwrite Behavior
(Required) Overwrite Behavior: when upgrade is not configured and an Application with same name already exists in the cluster, then following actions are available => Never, Always, SameAppTypeAndVersion.
Never will not remove the existing Application. This is the default behavior.
Always will remove the existing Application even if its Application type and Version is different from the Application being created.
SameAppTypeAndVersion will remove the existing Application only if its Application type and Version is same as the Application being created
Default value: SameAppTypeAndVersion
skipUpgradeSameTypeAndVersion
Skip upgrade for same Type and Version
(Optional) Indicates whether an upgrade will be skipped if the same application type and version already exists in the cluster, otherwise the upgrade fails during validation. If enabled, re-deployments are idempotent.
Default value: false
skipPackageValidation
Skip package validation
(Optional) Indicates whether the package should be validated or not before deployment. More information about package validation can be found here
Default value: false
useDiffPackage
Use Diff Package
(Optional) Diff package is created by task by comparing the package specified in Application Package input against the package which is currently registered in the target cluster. If a service version in cluster's current package is same as the new package, then this service package will be removed from new Application package. See more details about diff package here.
Default value: false
overridePublishProfileSettings
Override All Publish Profile Upgrade Settings
(Optional) This will override all upgrade settings with either the values specified below or the default value if not specified. More information about upgrade settings can be found here
Default value: false
isUpgrade
Upgrade the Application
(Optional) If false, the application will be overwritten.
Default value: true
unregisterUnusedVersions
Unregister Unused Versions
(Optional) Indicates whether all unused versions of the application type will be removed after an upgrade
Default value: true
upgradeMode
Upgrade Mode
(Required)
Default value: Monitored
FailureAction
FailureAction
(Required)
Default value: Rollback
UpgradeReplicaSetCheckTimeoutSec
UpgradeReplicaSetCheckTimeoutSec
(Optional)
TimeoutSec
TimeoutSec
(Optional)
ForceRestart
ForceRestart
(Optional)
Default value: false
HealthCheckRetryTimeoutSec
HealthCheckRetryTimeoutSec
(Optional)
HealthCheckWaitDurationSec
HealthCheckWaitDurationSec
(Optional)
HealthCheckStableDurationSec
HealthCheckStableDurationSec
(Optional)
UpgradeDomainTimeoutSec
UpgradeDomainTimeoutSec
(Optional)
ConsiderWarningAsError
ConsiderWarningAsError
(Optional)
Default value: false
DefaultServiceTypeHealthPolicy
DefaultServiceTypeHealthPolicy
(Optional)
MaxPercentUnhealthyDeployedApplications
MaxPercentUnhealthyDeployedApplications
(Optional)
UpgradeTimeoutSec
UpgradeTimeoutSec
(Optional)
ServiceTypeHealthPolicyMap
ServiceTypeHealthPolicyMap
(Optional)
configureDockerSettings
Configure Docker settings
Default value: false
registryCredentials
Registry Credentials Source
(Required) Choose how credentials for the Docker registry will be provided
Default value: AzureResourceManagerEndpoint
dockerRegistryEndpoint
Docker Registry Service Connection
(Required) Select a Docker registry service connection. Required for commands that need to authenticate with a registry.
Note: task will try to encrypt the registry secret before transmitting it to service fabric cluster. However, it needs cluster's server certificate to be installed on agent machine in order to do so. If certificate is not present, secret will not be encrypted
azureSubscriptionEndpoint
Azure subscription
(Required) Select an Azure subscription.
Note: task will try to encrypt the registry secret before transmitting it to service fabric cluster. However, it needs cluster's server certiticate to be installed on agent machine in order to do so. If certificate is not present, secret will not be encrypted
registryUserName
Registry User Name
(Optional) Username for the Docker registry
registryPassword
Registry Password
(Optional) Password for the Docker registry. If the password is not encrypted, it is recommended that you use a custom release pipeline secret variable to store it
passwordEncrypted
Password Encrypted
(Optional) It is recommended to encrypt your password using [Invoke-ServiceFabricEncryptText](https://docs.microsoft.com/azure/service-fabric/service-fabric-application-secret-management#encrypt-application-secrets). If you do not, and a certificate matching the Server Certificate Thumbprint in the Cluster Service Connection is installed on the build agent, it will be used to encrypt the password; otherwise an error will occur

Also see: Update Service Fabric Manifests task

Arguments

Argument Description
Publish Profile The location of the publish profile that specifies the settings to use for deployment, including the location of the target Service Fabric cluster. Can include wildcards and variables. Example:
$(system.defaultworkingdirectory)/**/drop/projectartifacts/**/PublishProfiles/Cloud.xml
Application Package The location of the Service Fabric application package to be deployed to the cluster. Can include wildcards and variables. Example: $(system.defaultworkingdirectory)/**/drop/applicationpackage
Cluster Connection The name of the Azure Service Fabric service connection defined in the TS/TFS project that describes the connection to the cluster.
Control options See Control options

Also see: Update Service Fabric App Versions task

Open source

This task is open source on GitHub. Feedback and contributions are welcome.