【问题标题】:Azure Service Fabric - change config settings for a deployed ApplicationAzure Service Fabric - 更改已部署应用程序的配置设置
【发布时间】:2016-09-20 22:04:29
【问题描述】:

如何更改 Service Fabric 中已部署应用程序的设置?

我有一个预配置的集群和一个部署到集群的应用程序,其中包含两个应用程序。我希望能够更改我的服务设置并让他们接受这些更改,但我不知道该怎么做。

以前,我们在云服务中使用辅助角色完成了所有服务,并且门户允许更改配置,但 Service Fabric 似乎没有这样做。在 Service Fabric Explorer 中,我可以深入了解该服务,转到 MANIFEST 并查看带有设置的 XML。我只是看不到编辑或更改它的方法。我很难在 SF 文档中找到解决此问题的任何内容。

【问题讨论】:

    标签: azure-service-fabric


    【解决方案1】:

    门户网站没有公开执行此操作的方法。它需要通过应用程序的升级来完成。只需更改设置 XML 文件中的设置并执行升级。在应用程序项目的 VS 发布对话框中,您可以通过更改配置包版本来适当地更新您的版本号,该版本会自动冒泡以更新包含的服务和应用程序版本。

    【讨论】:

    • 那么,重建应用程序并仅针对设置进行更新不会强制重新部署任何未更改的组件?这是我在阅读 Ryan Wike 在他的回答中链接到的文章后的理解。
    • 如果您是从 Visual Studio 升级,那么可以。 Visual Studio 会根据您正在部署的内容与集群中存在的内容之间的版本差异自动生成“差异包”。因此,如果您只更改了配置包的版本,那么这就是将打包的所有内容。如果您在 VS 之外生成包,则情况并非如此。
    【解决方案2】:

    基于 Matt Thalman 的回答,这里有关于修改应用程序或服务清单 XML 文件中的设置、更新版本号和执行应用程序升级的文档:Service Fabric application upgrade tutorial using Visual Studio。你也可以perform the app upgrade using PowerShell

    【讨论】:

      【解决方案3】:

      除上述答案外,添加一些 powershell 代码..

      我们可以使用下面的 powershell 代码从 powershell 连接到 Service Fabric 并获取应用程序参数,然后更新特定参数并重新部署..

      ### Change the connection here (from Profile-Cloud.xml
      $ConnectArgs = @{  
          ConnectionEndpoint="devxxxxxx.westus.cloudapp.azure.com:19000"
          X509Credential="true"
          ServerCertThumbprint="52BFxxxxxxxxxx"
          FindType="FindByThumbprint"
          FindValue="EF3A2xxxxxxxxxxxxxx"
          StoreLocation="CurrentUser"
          StoreName="My" 
          }
          
      Connect-ServiceFabricCluster @ConnectArgs
      
      $myApplication = Get-ServiceFabricApplication -ApplicationName fabric:/ABC.MyService 
      $appParamCollection = $myApplication.ApplicationParameters
      
      ### Update your parameter here..
      $applicationParameterMap.ElasticSearch_Username="sachin2"
      
      $applicationParameterMap = @{}
      foreach ($pair in $appParamCollection)
      {
          $applicationParameterMap.Add($pair.Name, $pair.Value);
      }
      
      ### Start Udpating
      Start-ServiceFabricApplicationUpgrade -ApplicationName $myApplication.ApplicationName.OriginalString -ApplicationTypeVersion $myApplication.ApplicationTypeVersion -ApplicationParameter $applicationParameterMap -Monitored -FailureAction Rollback -ForceRestart $true
      
      ### Check the status until it is Ready 
      (Get-ServiceFabricApplication -ApplicationName fabric:/ABC.MyService).ApplicationStatus
      
      ### Check the parameters to confirm those're updated 
      Get-ServiceFabricApplication -ApplicationName fabric:/ABC.MyService
      

      您可以根据您的要求更改或删除-ForceRestart

      【讨论】:

        最近更新 更多