c# - 如何获取位置(亲和区域)或名称集群(结构服务)

标签 c# azure-service-fabric affinity

我目前正在使用 fabric 服务的 web api。 需要获取结构服务集群的位置(亲和区域)。 即通过代码(c#)判断当前集群位于哪个位置 在网络 API 中。 或者我需要托管 Web API 的集群的名称。

在 webrole 或云服务中,可以使用 https://management.core.windows.net/ {0}/服务/托管服务

但我找不到集群的任何方法。

最佳答案

我不确定这是否有帮助,但请查看为项目创建的 ServiceEventSource。 ServiceMessage 方法向您展示了许多可从服务上下文获得的信息。

ServiceMessage(
    service.Context.ServiceName.ToString(),
    service.Context.ServiceTypeName,
    service.Context.ReplicaId,
    service.Context.PartitionId,
    service.Context.CodePackageActivationContext.ApplicationName,
    service.Context.CodePackageActivationContext.ApplicationTypeName,
    service.Context.NodeContext.NodeName,
    finalMessage);

您还可以查看 FabricClient

关于c# - 如何获取位置(亲和区域)或名称集群(结构服务),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38209108/

相关文章:

c# - 转换类型时遇到问题

c# - 如何获取名称和ID是动态的表单字段的值

azure - 将非 DataContract 类发送到 Azure Service Fabric Actor

python 3.6.0 : 'os' module does not have 'sched_getaffinity' method

c# - Automapper - 如何使用 automapper 将三个实体映射到一个实体?

c# - 如何计算/查找特定的 ListView 项目(类)?

azure - 如何更改本地 Service Fabric 默认启动 URL?

azure - 在 Azure Service Fabric 应用程序中存储配置值的位置

linux - 将进程固定到任何符合亲和性的 CPU

linux - 如何设置内核线程的亲和性?