azure - 在 Service Fabric 中,我可以使用应用程序参数更改 ServiceManifest.xml 文件中的参数吗?

标签 azure azure-service-fabric

我有一个 ApplicationManifest.xml 文件,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric"
   ApplicationTypeName="ServiceFabricTestType" ApplicationTypeVersion="1.9">
   <Parameters>
     <Parameter Name="Prop_BehavioursPath" DefaultValue="behaviours.yml"/>
     <Parameter Name="Prop_AliasesPath" DefaultValue="aliases.yml"/>
   </Parameters>
  <ServiceManifestImport>
  <ServiceManifestRef 
    ServiceManifestName="SummaryGenerator" 
    ServiceManifestVersion="1.9.0.0" 
    />
  </ServiceManifestImport>
</ApplicationManifest>

我想使用参数来调整我的 guest 托管服务的参数,在 ServiceManifest.xml 文件中声明,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric"
   Name="SummaryGenerator" Version="1.9.0.0">
   <ServiceTypes>
     <StatelessServiceType ServiceTypeName="SummaryGenerator" UseImplicitHost="true"/>
   </ServiceTypes>
   <CodePackage Name="code" Version="1.9.0.0">
   <EntryPoint>
     <ExeHost>
        <Program>MyProgram.exe</Program>
        <Arguments>&quot;LoadFrom=[Prop_AliasesPath]|[Prop_BehavioursPath]&quot;</Arguments>
        <ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
     </ExeHost>
   </EntryPoint>
  </CodePackage>
</ServiceManifest>

这显然不起作用,因为进入参数的属性被逐字对待,而不是从参数值解析。

我真正想做的是能够启动服务并为 Prop_BehavioursPath 和 Prop_AliasesPath 传递不同的值。在 Service Fabric 中是否有更好的方法来执行此操作?

正在运行的应用程序不了解 Service Fabric,将配置推送到它的唯一方法是通过命令参数。

最佳答案

看起来您无法做到这一点...相反,您可以尝试一种解决方法,编写一个小型 .NET 包装器来读取 sf 配置,然后启动 guest 可执行文件。您可以从子进程重定向 stdin/stdout 并 Hook 到其退出事件,以便主进程在子进程终止时终止。

关于azure - 在 Service Fabric 中,我可以使用应用程序参数更改 ServiceManifest.xml 文件中的参数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37488598/

相关文章:

azure - Windows Azure 无法本地启动

azure-service-fabric - 启动 Service Fabric 群集时出错 (v 1.5.175)

azure-service-fabric - Azure 开发测试实验室是否可用于 Service Fabric 集群?

asp.net - Service Fabric 中的 .NET Core RC2

azure - 诊断 Azure 有状态参与者

Azure Service Fabric 中的 Java Spring Boot

azure - 如何从window azure访问事件日志

c# - 尝试将训练图像上传到自定义视觉项目时出现未经授权的错误

python - Azure-sdk-for-python AKS : how to add a new nodepool using

azure - 我可以在没有 Azure 云服务的情况下使用 Azure ML 吗?