@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="BusType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="RabbitMQ_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="RabbitMQPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="5672" EndpointRef="RabbitMQTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="RabbitMQ" ServiceDnsName="rabbitmq.eshoponservicefabricbus" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="RabbitMQType" InstanceCount="[RabbitMQ_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Bus" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="RabbitMQ_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Bus" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Bus" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>f29e27c9-0d5e-4a57-adbf-dd651649d2a1</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\RabbitMQPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\RabbitMQPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="NoSQLType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="MongoDB_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="MongoDBPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="27017" EndpointRef="MongoDBTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="MongoDB" ServiceDnsName="mongodb.eshoponservicefabricnosql" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="MongoDBType" InstanceCount="[MongoDB_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/NoSQL" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="MongoDB_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/NoSQL" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/NoSQL" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>eb070036-ec60-49a6-88e1-562a2043c3d7</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\MongoDBPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\MongoDBPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="RedisType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="BasketData_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="BasketDataPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="6379" EndpointRef="BasketDataTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="BasketData" ServiceDnsName="basketdata.eshoponservicefabricredis" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="BasketDataType" InstanceCount="[BasketData_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Redis" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="BasketData_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Redis" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Redis" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>17acd9ea-8f16-4091-aa29-c67002971eee</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\BasketDataPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\BasketDataPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="SqlType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="SqlServer_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="SqlServerPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="1433" EndpointRef="SqlServerTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="SqlServer" ServiceDnsName="sqlserver.eshoponservicefabricsql" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="SqlServerType" InstanceCount="[SqlServer_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Sql" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="SqlServer_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Sql" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Sql" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>65a83188-79c1-47ad-931d-8e8a87247408</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\SqlServerPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\SqlServerPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="BusType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="RabbitMQ_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="RabbitMQPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="5672" EndpointRef="RabbitMQTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="RabbitMQ" ServiceDnsName="rabbitmq.eshoponservicefabricbus" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="RabbitMQType" InstanceCount="[RabbitMQ_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Bus" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="RabbitMQ_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Bus" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Bus" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>f29e27c9-0d5e-4a57-adbf-dd651649d2a1</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\RabbitMQPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\RabbitMQPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="NoSQLType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="MongoDB_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="MongoDBPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="27017" EndpointRef="MongoDBTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="MongoDB" ServiceDnsName="mongodb.eshoponservicefabricnosql" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="MongoDBType" InstanceCount="[MongoDB_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/NoSQL" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="MongoDB_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/NoSQL" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/NoSQL" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>eb070036-ec60-49a6-88e1-562a2043c3d7</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\MongoDBPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\MongoDBPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ApplicationManifest ApplicationTypeName="RedisType" | |||
ApplicationTypeVersion="1.0.0" | |||
xmlns="http://schemas.microsoft.com/2011/01/fabric" | |||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="BasketData_InstanceCount" DefaultValue="-1" /> | |||
</Parameters> | |||
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion | |||
should match the Name and Version attributes of the ServiceManifest element defined in the | |||
ServiceManifest.xml file. --> | |||
<ServiceManifestImport> | |||
<ServiceManifestRef ServiceManifestName="BasketDataPkg" ServiceManifestVersion="1.0.0" /> | |||
<ConfigOverrides /> | |||
<Policies> | |||
<ContainerHostPolicies CodePackageRef="Code"> | |||
<PortBinding ContainerPort="6379" EndpointRef="BasketDataTypeEndpoint"/> | |||
</ContainerHostPolicies> | |||
</Policies> | |||
</ServiceManifestImport> | |||
<DefaultServices> | |||
<!-- The section below creates instances of service types, when an instance of this | |||
application type is created. You can also create one or more instances of service type using the | |||
ServiceFabric PowerShell module. | |||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> | |||
<Service Name="BasketData" ServiceDnsName="basketdata.eshoponservicefabricredis" ServicePackageActivationMode="ExclusiveProcess"> | |||
<StatelessService ServiceTypeName="BasketDataType" InstanceCount="[BasketData_InstanceCount]"> | |||
<SingletonPartition /> | |||
</StatelessService> | |||
</Service> | |||
</DefaultServices> | |||
</ApplicationManifest> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Redis" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
<Parameter Name="BasketData_InstanceCount" Value="-1" /> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Redis" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Application Name="fabric:/Redis" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<Parameters> | |||
</Parameters> | |||
</Application> |
@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster. | |||
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" /> | |||
Example showing parameters for a cluster that uses certificate security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
X509Credential="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" | |||
FindType="FindByThumbprint" | |||
FindValue="9876543210987654321098765432109876543210" | |||
StoreLocation="CurrentUser" | |||
StoreName="My" /> | |||
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security: | |||
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" | |||
AzureActiveDirectory="true" | |||
ServerCertThumbprint="0123456789012345678901234567890123456789" /> | |||
--> | |||
<ClusterConnectionParameters ConnectionEndpoint="#{your_sf_dns}#:19000" /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools"> | |||
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster. | |||
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet. | |||
For a local cluster, you would typically not use any parameters. | |||
For example: <ClusterConnectionParameters /> | |||
--> | |||
<ClusterConnectionParameters /> | |||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" /> | |||
</PublishProfile> |
@ -0,0 +1,46 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles"> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>17acd9ea-8f16-4091-aa29-c67002971eee</ProjectGuid> | |||
<ProjectVersion>1.7</ProjectVersion> | |||
<MinToolsVersion>1.5</MinToolsVersion> | |||
<SupportedMSBuildNuGetPackageVersion>1.6</SupportedMSBuildNuGetPackageVersion> | |||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|x64"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|x64"> | |||
<Configuration>Release</Configuration> | |||
<Platform>x64</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" /> | |||
<None Include="ApplicationParameters\Cloud.xml" /> | |||
<None Include="ApplicationParameters\Local.1Node.xml" /> | |||
<None Include="ApplicationParameters\Local.5Node.xml" /> | |||
<None Include="PublishProfiles\Cloud.xml" /> | |||
<None Include="PublishProfiles\Local.1Node.xml" /> | |||
<None Include="PublishProfiles\Local.5Node.xml" /> | |||
<None Include="Scripts\Deploy-FabricApplication.ps1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="ApplicationPackageRoot\BasketDataPkg\Config\Settings.xml" /> | |||
<Content Include="ApplicationPackageRoot\BasketDataPkg\ServiceManifest.xml" /> | |||
<Content Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | |||
<PropertyGroup> | |||
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath> | |||
</PropertyGroup> | |||
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" /> | |||
<Import Project="..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" /> | |||
<Target Name="ValidateMSBuildFiles"> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.1\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" /> | |||
</Target> | |||
</Project> |
@ -0,0 +1,258 @@ | |||
<# | |||
.SYNOPSIS | |||
Deploys a Service Fabric application type to a cluster. | |||
.DESCRIPTION | |||
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project. | |||
.NOTES | |||
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary. | |||
.PARAMETER PublishProfileFile | |||
Path to the file containing the publish profile. | |||
.PARAMETER ApplicationPackagePath | |||
Path to the folder of the packaged Service Fabric application. | |||
.PARAMETER DeployOnly | |||
Indicates that the Service Fabric application should not be created or upgraded after registering the application type. | |||
.PARAMETER ApplicationParameter | |||
Hashtable of the Service Fabric application parameters to be used for the application. | |||
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Indicates whether to unregister any unused application versions that exist after an upgrade is finished. | |||
.PARAMETER OverrideUpgradeBehavior | |||
Indicates the behavior used to override the upgrade settings specified by the publish profile. | |||
'None' indicates that the upgrade settings will not be overridden. | |||
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile. | |||
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile. | |||
.PARAMETER UseExistingClusterConnection | |||
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored. | |||
.PARAMETER OverwriteBehavior | |||
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application. | |||
'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. | |||
.PARAMETER SkipPackageValidation | |||
Switch signaling whether the package should be validated or not before deployment. | |||
.PARAMETER SecurityToken | |||
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory. | |||
.PARAMETER CopyPackageTimeoutSec | |||
Timeout in seconds for copying application package to image store. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' | |||
Deploy the application using the default package location for a Debug build. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication | |||
Deploy the application but do not create the application instance. | |||
.EXAMPLE | |||
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'} | |||
Deploy the application by providing values for parameters that are defined in the application manifest. | |||
#> | |||
Param | |||
( | |||
[String] | |||
$PublishProfileFile, | |||
[String] | |||
$ApplicationPackagePath, | |||
[Switch] | |||
$DeployOnly, | |||
[Hashtable] | |||
$ApplicationParameter, | |||
[Boolean] | |||
$UnregisterUnusedApplicationVersionsAfterUpgrade, | |||
[String] | |||
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')] | |||
$OverrideUpgradeBehavior = 'None', | |||
[Switch] | |||
$UseExistingClusterConnection, | |||
[String] | |||
[ValidateSet('Never','Always','SameAppTypeAndVersion')] | |||
$OverwriteBehavior = 'Never', | |||
[Switch] | |||
$SkipPackageValidation, | |||
[String] | |||
$SecurityToken, | |||
[int] | |||
$CopyPackageTimeoutSec | |||
) | |||
function Read-XmlElementAsHashtable | |||
{ | |||
Param ( | |||
[System.Xml.XmlElement] | |||
$Element | |||
) | |||
$hashtable = @{} | |||
if ($Element.Attributes) | |||
{ | |||
$Element.Attributes | | |||
ForEach-Object { | |||
$boolVal = $null | |||
if ([bool]::TryParse($_.Value, [ref]$boolVal)) { | |||
$hashtable[$_.Name] = $boolVal | |||
} | |||
else { | |||
$hashtable[$_.Name] = $_.Value | |||
} | |||
} | |||
} | |||
return $hashtable | |||
} | |||
function Read-PublishProfile | |||
{ | |||
Param ( | |||
[ValidateScript({Test-Path $_ -PathType Leaf})] | |||
[String] | |||
$PublishProfileFile | |||
) | |||
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile) | |||
$publishProfile = @{} | |||
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters") | |||
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment") | |||
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters") | |||
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment")) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters") | |||
if ($publishProfile.UpgradeDeployment["Mode"]) | |||
{ | |||
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true | |||
} | |||
} | |||
$publishProfileFolder = (Split-Path $PublishProfileFile) | |||
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path) | |||
return $publishProfile | |||
} | |||
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path) | |||
if (!$PublishProfileFile) | |||
{ | |||
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml" | |||
} | |||
if (!$ApplicationPackagePath) | |||
{ | |||
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release" | |||
} | |||
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath | |||
$publishProfile = Read-PublishProfile $PublishProfileFile | |||
if (-not $UseExistingClusterConnection) | |||
{ | |||
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters | |||
if ($SecurityToken) | |||
{ | |||
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken | |||
} | |||
try | |||
{ | |||
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) | |||
} | |||
catch [System.Fabric.FabricObjectClosedException] | |||
{ | |||
Write-Warning "Service Fabric cluster may not be connected." | |||
throw | |||
} | |||
} | |||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK" | |||
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath | |||
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1" | |||
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade' | |||
$PublishParameters = @{ | |||
'ApplicationPackagePath' = $ApplicationPackagePath | |||
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile | |||
'ApplicationParameter' = $ApplicationParameter | |||
'ErrorAction' = 'Stop' | |||
} | |||
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec | |||
} | |||
if ($publishProfile.CopyPackageParameters.CompressPackage) | |||
{ | |||
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage | |||
} | |||
# CopyPackageTimeoutSec parameter overrides the value from the publish profile | |||
if ($CopyPackageTimeoutSec) | |||
{ | |||
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec | |||
} | |||
if ($IsUpgrade) | |||
{ | |||
$Action = "RegisterAndUpgrade" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters | |||
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade') | |||
{ | |||
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior. | |||
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['UpgradeParameters'] = $UpgradeParameters | |||
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade | |||
Publish-UpgradedServiceFabricApplication @PublishParameters | |||
} | |||
else | |||
{ | |||
$Action = "RegisterAndCreate" | |||
if ($DeployOnly) | |||
{ | |||
$Action = "Register" | |||
} | |||
$PublishParameters['Action'] = $Action | |||
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior | |||
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation | |||
Publish-NewServiceFabricApplication @PublishParameters | |||
} |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.1" targetFramework="net461" /> | |||
</packages> |