Azure Service Fabric - 更改已部署应用程序的配置设置
Azure Service Fabric - change config settings for a deployed Application
如何更改 Service Fabric 中已部署应用程序的设置?
我有一个配置的集群和一个部署到集群的应用程序,其中有两个应用程序。我希望能够更改我的服务设置并让他们接受这些更改,但我不知道该怎么做。
以前,我们在云服务中完成了所有具有辅助角色的服务,并且门户允许更改配置,但它似乎没有为 Service Fabric 这样做。从 Service Fabric Explorer 我可以深入到服务,转到 MANIFEST 并使用设置查看 XML。我只是看不到编辑或更改它的方法。我很难在 SF 文档中找到解决此问题的任何内容。
该门户网站没有提供执行此操作的方法。它需要通过升级应用程序来完成。只需更改设置 XML 文件中的设置并执行升级。在应用程序项目的 VS 发布对话框中,您可以通过更改配置包版本来适当更新版本号,配置包版本将自动冒泡以更新包含的服务和应用程序版本。
基于 Matt Thalman 的回答,这里有关于修改应用程序或服务清单 XML 文件中的设置、更新版本号和执行应用程序升级的文档:Service Fabric application upgrade tutorial using Visual Studio. You can also perform the app upgrade using PowerShell.
除上述答案外,添加一些 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
如何更改 Service Fabric 中已部署应用程序的设置?
我有一个配置的集群和一个部署到集群的应用程序,其中有两个应用程序。我希望能够更改我的服务设置并让他们接受这些更改,但我不知道该怎么做。
以前,我们在云服务中完成了所有具有辅助角色的服务,并且门户允许更改配置,但它似乎没有为 Service Fabric 这样做。从 Service Fabric Explorer 我可以深入到服务,转到 MANIFEST 并使用设置查看 XML。我只是看不到编辑或更改它的方法。我很难在 SF 文档中找到解决此问题的任何内容。
该门户网站没有提供执行此操作的方法。它需要通过升级应用程序来完成。只需更改设置 XML 文件中的设置并执行升级。在应用程序项目的 VS 发布对话框中,您可以通过更改配置包版本来适当更新版本号,配置包版本将自动冒泡以更新包含的服务和应用程序版本。
基于 Matt Thalman 的回答,这里有关于修改应用程序或服务清单 XML 文件中的设置、更新版本号和执行应用程序升级的文档:Service Fabric application upgrade tutorial using Visual Studio. You can also perform the app upgrade using PowerShell.
除上述答案外,添加一些 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