Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aelij/8db0a766b315494065390978b68dd97a to your computer and use it in GitHub Desktop.
Save aelij/8db0a766b315494065390978b68dd97a to your computer and use it in GitHub Desktop.
Cmdlet to create a skeleton Service Fabric application package from the image store. Can be used for partial configuration/data packages upgrades.
function Create-ServiceFabricApplicationPackageSkeleton
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[string] $ApplicationTypeName,
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[string] $ApplicationTypeVersion,
[Parameter(Mandatory=$true)]
[string] $OutputPath
)
$OutputPath = [IO.Path]::Combine((Get-Location), $OutputPath)
New-Item -Path $OutputPath -ItemType Directory -ErrorAction Ignore | Out-Null
$manifest = Get-ServiceFabricApplicationManifest -ApplicationTypeName $ApplicationTypeName -ApplicationTypeVersion $ApplicationTypeVersion
$manifest | Out-File -FilePath ([IO.Path]::Combine($OutputPath, 'ApplicationManifest.xml'))
$manifestXml = [xml] $manifest;
$serviceManifestRefList = $manifestXml.GetElementsByTagName('ServiceManifestRef')
foreach ($serviceManifestRef in $serviceManifestRefList)
{
$serviceManifestName = $serviceManifestRef.ServiceManifestName
New-Item -Path ([IO.Path]::Combine($OutputPath, $serviceManifestName)) -ItemType Directory -ErrorAction Ignore | Out-Null
$serviceManifest = Get-ServiceFabricServiceManifest -ApplicationTypeName $ApplicationTypeName -ApplicationTypeVersion $ApplicationTypeVersion `
-ServiceManifestName $serviceManifestName
$serviceManifest | Out-File -FilePath ([IO.Path]::Combine($OutputPath, $serviceManifestName, 'ServiceManifest.xml'))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment