diff --git a/Services/WcfService/Calculator.Client/App.config b/Services/WcfService/Calculator.Client/App.config index 88fa402..ecdcf8a 100644 --- a/Services/WcfService/Calculator.Client/App.config +++ b/Services/WcfService/Calculator.Client/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Services/WcfService/Calculator.Client/Calculator.Client.csproj b/Services/WcfService/Calculator.Client/Calculator.Client.csproj index 8203091..4dfbf6d 100644 --- a/Services/WcfService/Calculator.Client/Calculator.Client.csproj +++ b/Services/WcfService/Calculator.Client/Calculator.Client.csproj @@ -9,9 +9,10 @@ Properties Calculator.Client Calculator.Client - v4.5.2 + v4.7.2 512 true + AnyCPU diff --git a/Services/WcfService/Calculator.Common/Calculator.Common.csproj b/Services/WcfService/Calculator.Common/Calculator.Common.csproj index 846d300..a4d40c9 100644 --- a/Services/WcfService/Calculator.Common/Calculator.Common.csproj +++ b/Services/WcfService/Calculator.Common/Calculator.Common.csproj @@ -9,8 +9,9 @@ Properties Calculator.Common Calculator.Common - v4.5.2 + v4.7.2 512 + true diff --git a/Services/WcfService/Calculator.Service/App.config b/Services/WcfService/Calculator.Service/App.config index 6584bb4..82b9527 100644 --- a/Services/WcfService/Calculator.Service/App.config +++ b/Services/WcfService/Calculator.Service/App.config @@ -1,6 +1,18 @@ - + - + - \ No newline at end of file + + + + + + + + + + + + + diff --git a/Services/WcfService/Calculator.Service/Calculator.Service.csproj b/Services/WcfService/Calculator.Service/Calculator.Service.csproj index 5cdb714..3c73867 100644 --- a/Services/WcfService/Calculator.Service/Calculator.Service.csproj +++ b/Services/WcfService/Calculator.Service/Calculator.Service.csproj @@ -9,9 +9,11 @@ Properties Calculator.Service Calculator.Service - v4.5.2 + v4.7.2 512 true + True + true @@ -36,43 +38,71 @@ $(AdditionalFileItemNames);None - - ..\packages\Microsoft.ServiceFabric.Data.2.3.301\lib\net45\Microsoft.ServiceFabric.Data.dll - True + + ..\packages\Microsoft.ServiceFabric.Data.6.1.1653\lib\net452\Microsoft.ServiceFabric.Data.dll + + + ..\packages\Microsoft.ServiceFabric.Data.Extensions.6.1.1653\lib\net452\Microsoft.ServiceFabric.Data.Extensions.dll - ..\packages\Microsoft.ServiceFabric.Data.2.3.301\lib\net45\Microsoft.ServiceFabric.Data.Interfaces.dll - True + ..\packages\Microsoft.ServiceFabric.Data.Interfaces.6.1.1653\lib\net452\Microsoft.ServiceFabric.Data.Interfaces.dll - - ..\packages\Microsoft.ServiceFabric.5.3.301\lib\net45\Microsoft.ServiceFabric.Internal.dll - True + + ..\packages\Microsoft.ServiceFabric.Diagnostics.Internal.6.1.1653\lib\net452\Microsoft.ServiceFabric.Diagnostics.dll - - ..\packages\Microsoft.ServiceFabric.5.3.301\lib\net45\Microsoft.ServiceFabric.Internal.Strings.dll - True + + ..\packages\Microsoft.ServiceFabric.FabricTransport.Internal.6.1.1653\lib\net452\Microsoft.ServiceFabric.FabricTransport.dll - - ..\packages\Microsoft.ServiceFabric.Services.2.3.301\lib\net45\Microsoft.ServiceFabric.Services.dll - True + + ..\packages\Microsoft.ServiceFabric.FabricTransport.Internal.6.1.1653\lib\net452\Microsoft.ServiceFabric.FabricTransport.V2.dll - - ..\packages\Microsoft.ServiceFabric.Services.Wcf.2.3.301\lib\net45\Microsoft.ServiceFabric.Services.Wcf.dll - True + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\Microsoft.ServiceFabric.Internal.dll + + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\Microsoft.ServiceFabric.Internal.Strings.dll + + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\Microsoft.ServiceFabric.Preview.dll + + + ..\packages\Microsoft.ServiceFabric.Data.Extensions.6.1.1653\lib\net452\Microsoft.ServiceFabric.ReliableCollection.Interop.dll + + + ..\packages\Microsoft.ServiceFabric.Services.6.1.1653\lib\net452\Microsoft.ServiceFabric.Services.dll + + + ..\packages\Microsoft.ServiceFabric.Services.Remoting.6.1.1653\lib\net452\Microsoft.ServiceFabric.Services.Remoting.dll + + + ..\packages\Microsoft.ServiceFabric.Services.Wcf.6.1.1653\lib\net45\Microsoft.ServiceFabric.Services.Wcf.dll ..\packages\Microsoft.ServiceFabric.Services.2.3.301\lib\net45\ServiceFabricServiceModel.dll True + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\StartupServicesModel.dll + + + ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll + - - ..\packages\Microsoft.ServiceFabric.5.3.301\lib\net45\System.Fabric.dll - True + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\System.Fabric.dll - - ..\packages\Microsoft.ServiceFabric.5.3.301\lib\net45\System.Fabric.Strings.dll - True + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\System.Fabric.Management.ServiceModel.dll + + + ..\packages\Microsoft.ServiceFabric.9.1.1653\lib\net452\System.Fabric.Strings.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll diff --git a/Services/WcfService/Calculator.Service/packages.config b/Services/WcfService/Calculator.Service/packages.config index e0c5008..e6bacaa 100644 --- a/Services/WcfService/Calculator.Service/packages.config +++ b/Services/WcfService/Calculator.Service/packages.config @@ -1,7 +1,15 @@  - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/Services/WcfService/Calculator/CalculatorApp.sfproj b/Services/WcfService/Calculator/CalculatorApp.sfproj index f2df9ab..34038a1 100644 --- a/Services/WcfService/Calculator/CalculatorApp.sfproj +++ b/Services/WcfService/Calculator/CalculatorApp.sfproj @@ -1,9 +1,11 @@  - + 6c3496ae-8fcd-451a-a874-6a89b7ec8545 - 1.3 + 2.1 + 1.7.6 + 1.5 @@ -36,5 +38,9 @@ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets - + + + + + \ No newline at end of file diff --git a/Services/WcfService/Calculator/Scripts/Deploy-FabricApplication.ps1 b/Services/WcfService/Calculator/Scripts/Deploy-FabricApplication.ps1 index 9b43f36..2897b10 100644 --- a/Services/WcfService/Calculator/Scripts/Deploy-FabricApplication.ps1 +++ b/Services/WcfService/Calculator/Scripts/Deploy-FabricApplication.ps1 @@ -14,7 +14,7 @@ Path to the file containing the publish profile. .PARAMETER ApplicationPackagePath Path to the folder of the packaged Service Fabric application. -.PARAMETER DeloyOnly +.PARAMETER DeployOnly Indicates that the Service Fabric application should not be created or upgraded after registering the application type. .PARAMETER ApplicationParameter @@ -139,6 +139,7 @@ function Read-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")) { @@ -196,6 +197,29 @@ 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" @@ -212,14 +236,11 @@ if ($IsUpgrade) $UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } } - if ($CopyPackageTimeoutSec) - { - Publish-UpgradedServiceFabricApplication -ApplicationPackagePath $ApplicationPackagePath -ApplicationParameterFilePath $publishProfile.ApplicationParameterFile -Action $Action -UpgradeParameters $UpgradeParameters -ApplicationParameter $ApplicationParameter -UnregisterUnusedVersions:$UnregisterUnusedApplicationVersionsAfterUpgrade -CopyPackageTimeoutSec $CopyPackageTimeoutSec -ErrorAction Stop - } - else - { - Publish-UpgradedServiceFabricApplication -ApplicationPackagePath $ApplicationPackagePath -ApplicationParameterFilePath $publishProfile.ApplicationParameterFile -Action $Action -UpgradeParameters $UpgradeParameters -ApplicationParameter $ApplicationParameter -UnregisterUnusedVersions:$UnregisterUnusedApplicationVersionsAfterUpgrade -ErrorAction Stop - } + $PublishParameters['Action'] = $Action + $PublishParameters['UpgradeParameters'] = $UpgradeParameters + $PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade + + Publish-UpgradedServiceFabricApplication @PublishParameters } else { @@ -228,13 +249,10 @@ else { $Action = "Register" } + + $PublishParameters['Action'] = $Action + $PublishParameters['OverwriteBehavior'] = $OverwriteBehavior + $PublishParameters['SkipPackageValidation'] = $SkipPackageValidation - if ($CopyPackageTimeoutSec) - { - Publish-NewServiceFabricApplication -ApplicationPackagePath $ApplicationPackagePath -ApplicationParameterFilePath $publishProfile.ApplicationParameterFile -Action $Action -ApplicationParameter $ApplicationParameter -OverwriteBehavior $OverwriteBehavior -SkipPackageValidation:$SkipPackageValidation -CopyPackageTimeoutSec $CopyPackageTimeoutSec -ErrorAction Stop - } - else - { - Publish-NewServiceFabricApplication -ApplicationPackagePath $ApplicationPackagePath -ApplicationParameterFilePath $publishProfile.ApplicationParameterFile -Action $Action -ApplicationParameter $ApplicationParameter -OverwriteBehavior $OverwriteBehavior -SkipPackageValidation:$SkipPackageValidation -ErrorAction Stop - } + Publish-NewServiceFabricApplication @PublishParameters } \ No newline at end of file diff --git a/Services/WcfService/Calculator/packages.config b/Services/WcfService/Calculator/packages.config index b681b82..ad8665e 100644 --- a/Services/WcfService/Calculator/packages.config +++ b/Services/WcfService/Calculator/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Services/WordCount/README.md b/Services/WordCount/README.md new file mode 100644 index 0000000..c319822 --- /dev/null +++ b/Services/WordCount/README.md @@ -0,0 +1,22 @@ +## Run this sample + +Alphabet partitions is an intro to partitioning stateful services in Service Fabric. It uses letters of the alphabet as partition keys into a stateful service with 26 partitions - one for each letter of the alphabet. + +To run this services: + +1. Open the .sln solution file in Visual Studio 2019 or 2022 +2. Install latest runtime and SDK from here: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-get-started +3. Set WordCount as Startup Project +4. Press F5 to run + +You can access the application in a web browser by going to: + +**http://localhost:8081/WordCount/ + + +Try different values for lastname to see data get sent to different partitions. + +## Next Steps + +- [Read more about ReliableServices and Reliable Collections ](https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-introduction) + \ No newline at end of file diff --git a/Services/WordCount/WordCount.Common/packages.config b/Services/WordCount/WordCount.Common/packages.config index e82a2b2..8c39b97 100644 --- a/Services/WordCount/WordCount.Common/packages.config +++ b/Services/WordCount/WordCount.Common/packages.config @@ -1,9 +1,9 @@  - - - - - + + + + + \ No newline at end of file diff --git a/Services/WordCount/WordCount.Service/WordCount.Service.csproj b/Services/WordCount/WordCount.Service/WordCount.Service.csproj index b6564c8..bc84dc5 100644 --- a/Services/WordCount/WordCount.Service/WordCount.Service.csproj +++ b/Services/WordCount/WordCount.Service/WordCount.Service.csproj @@ -11,6 +11,7 @@ WordCount.Service v4.5 512 + True x64 diff --git a/Services/WordCount/WordCount.Service/packages.config b/Services/WordCount/WordCount.Service/packages.config index 4044a52..95649c6 100644 --- a/Services/WordCount/WordCount.Service/packages.config +++ b/Services/WordCount/WordCount.Service/packages.config @@ -1,18 +1,18 @@  - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Services/WordCount/WordCount.WebService/WordCount.WebService.csproj b/Services/WordCount/WordCount.WebService/WordCount.WebService.csproj index 1db115f..206a206 100644 --- a/Services/WordCount/WordCount.WebService/WordCount.WebService.csproj +++ b/Services/WordCount/WordCount.WebService/WordCount.WebService.csproj @@ -11,6 +11,7 @@ WordCount.WebService v4.5 512 + True x64 diff --git a/Services/WordCount/WordCount.WebService/packages.config b/Services/WordCount/WordCount.WebService/packages.config index c98ce96..01ae522 100644 --- a/Services/WordCount/WordCount.WebService/packages.config +++ b/Services/WordCount/WordCount.WebService/packages.config @@ -1,17 +1,17 @@  - - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/Services/WordCount/WordCount/Scripts/Deploy-FabricApplication.ps1 b/Services/WordCount/WordCount/Scripts/Deploy-FabricApplication.ps1 index 6cedbf7..74e3990 100644 --- a/Services/WordCount/WordCount/Scripts/Deploy-FabricApplication.ps1 +++ b/Services/WordCount/WordCount/Scripts/Deploy-FabricApplication.ps1 @@ -14,7 +14,7 @@ Path to the file containing the publish profile. .PARAMETER ApplicationPackagePath Path to the folder of the packaged Service Fabric application. -.PARAMETER DeloyOnly +.PARAMETER DeployOnly Indicates that the Service Fabric application should not be created or upgraded after registering the application type. .PARAMETER ApplicationParameter @@ -25,7 +25,7 @@ Indicates whether to unregister any unused application versions that exist after .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 overriden. +'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. @@ -44,6 +44,9 @@ Switch signaling whether the package should be validated or not before deploymen .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' @@ -92,7 +95,10 @@ Param $SkipPackageValidation, [String] - $SecurityToken + $SecurityToken, + + [int] + $CopyPackageTimeoutSec ) function Read-XmlElementAsHashtable @@ -133,6 +139,7 @@ function Read-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")) { @@ -190,6 +197,29 @@ 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" @@ -206,7 +236,11 @@ if ($IsUpgrade) $UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true } } - Publish-UpgradedServiceFabricApplication -ApplicationPackagePath $ApplicationPackagePath -ApplicationParameterFilePath $publishProfile.ApplicationParameterFile -Action $Action -UpgradeParameters $UpgradeParameters -ApplicationParameter $ApplicationParameter -UnregisterUnusedVersions:$UnregisterUnusedApplicationVersionsAfterUpgrade -ErrorAction Stop + $PublishParameters['Action'] = $Action + $PublishParameters['UpgradeParameters'] = $UpgradeParameters + $PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade + + Publish-UpgradedServiceFabricApplication @PublishParameters } else { @@ -215,6 +249,10 @@ else { $Action = "Register" } + + $PublishParameters['Action'] = $Action + $PublishParameters['OverwriteBehavior'] = $OverwriteBehavior + $PublishParameters['SkipPackageValidation'] = $SkipPackageValidation - Publish-NewServiceFabricApplication -ApplicationPackagePath $ApplicationPackagePath -ApplicationParameterFilePath $publishProfile.ApplicationParameterFile -Action $Action -ApplicationParameter $ApplicationParameter -OverwriteBehavior $OverwriteBehavior -SkipPackageValidation:$SkipPackageValidation -ErrorAction Stop + Publish-NewServiceFabricApplication @PublishParameters } \ No newline at end of file diff --git a/Services/WordCount/WordCount/WordCount.sfproj b/Services/WordCount/WordCount/WordCount.sfproj index dbe5505..9b6f658 100644 --- a/Services/WordCount/WordCount/WordCount.sfproj +++ b/Services/WordCount/WordCount/WordCount.sfproj @@ -1,11 +1,13 @@  - + de5d59b0-1752-4cf7-a980-4edddba8935e - 1.2 + 2.1 v4.5 true + 1.7.7 + 1.5 @@ -39,5 +41,9 @@ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets - + + + + + \ No newline at end of file diff --git a/Services/WordCount/WordCount/packages.config b/Services/WordCount/WordCount/packages.config index 2c11cca..e500a50 100644 --- a/Services/WordCount/WordCount/packages.config +++ b/Services/WordCount/WordCount/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file