Create certificate for Fabric secure cluster

When you’re working on CI/CD security is always important and certificates are quite useful.

Azure Service Fabric management with certificates is very easy, but creating certificate might be a bit confusing.

However, like most everything it can be easily automated with PowerShell and here’s example for you:

<#	
	.NOTES
	===========================================================================
	 Created on:   	Jul 2017
	 Created by:   	Dmitriy Kagarlickij
	 Contact: 	    dmitriy@kagarlickij.com
	===========================================================================
	.DESCRIPTION
		ServiceFabricRPHelpers module is from: https://github.com/ChackDan/Service-Fabric/tree/master/Scripts/ServiceFabricRPHelpers
#>

Login-AzureRmAccount

if ($(Test-Path -Path "C:\Service-Fabric-master") -ne $true) {
    Invoke-WebRequest -Uri https://github.com/ChackDan/Service-Fabric/archive/master.zip -OutFile "C:\Service-Fabric-master.zip"
    Expand-Archive "C:\Service-Fabric-master.zip" -DestinationPath "C:\"
    Remove-Item -Path "C:\Service-Fabric-master.zip"
}

Import-Module "C:\Service-Fabric-master\Scripts\ServiceFabricRPHelpers\ServiceFabricRPHelpers.psm1"

if ($(Test-Path -Path "C:\AzureCertificates") -ne $true) {
    New-Item -ItemType Directory -Path "C:\" -Name "AzureCertificates"
}

Invoke-AddCertToKeyVault `
-SubscriptionId "d1b58865-90ce-447e-981d-eaca81001f58" `
-DnsName "kag-fb-cl1.westus.mydomain.com" `
-ResourceGroupName "kag-rg1" `
-Location "westus" `
-VaultName "kag-kw1" `
-CertificateName "kagcert1" `
-Password "Password" `
-CreateSelfSignedCertificate `
-OutputPath "C:\AzureCertificates" `
| Out-File "C:\AzureCertificates\certParameters.txt"

 

When script is done, you’ll get everything you need:

I hope this info will be useful for you, and if you need any help feel free to use contact form on the main page.