Deploy Azure Service Fabric Application with VSTS

The Azure Service Fabric is one of the most mature platforms for building microservice-based applications. It has a lot of built in functionality and integrates great with Visual Studio and Visual Studio Team Services (VSTS).

If you want to start playing around with it you can use a lot of samples from GitHub. I always use the VisualObject projects because it’s nice to show Automatic Update and Self-Heeling.

To build a azure service application you can use the special template. You don’t have to change anything – just run the build with the default steps.

Create-ServiceFabric-Build

The output generates a application package and project artifacts containing all projects from the solution.

Build-Artifafacts-For-ServiceFabric

To create a Release definition you can also use the template to start with.

create-release-definition

In the “Deploy Service Fabric Application” click “Add” to add a new Service Connection.

Add-service-connection

Depending the configuration of your cluster you can choose Azure Active Directory or Certificate Based authentication. My cluster is configured to use certificate bases authentication.

image

If your certificate is stored in KeyVault you can use the following script to get the certificate and password.

Login-AzureRmAccount
$s = Get-AzureKeyVaultSecret -VaultName {KeyVaultName} -Name {CertThumbPrint} -Version {Version}

$arr = ([System.Convert]::FromBase64String($s.SecretValueText))
$json = ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString($arr))

$json.data

$json.password

If you have to certificate as a pfx you can do [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes("C:\path\to\certificate.pfx")).

If you want, you can override the upgrade settings from the publish profile.

image

This will ensure that every change is rolled out to the cluster.

That’s it. if you have checked continuous integration and continuous deployment every change to your repository will now trigger a release to your cluster.

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s