如何以编程方式检索SF actor服务名称?

时间:2017-07-06 15:49:31

标签: c# configuration azure-service-fabric service-fabric-actor

有没有办法以编程方式从其他服务中的ServiceManifest.xml中检索DefaultService Name属性?示例:Web API服务中的actor的服务名称。我试图避免硬编码。

1 个答案:

答案 0 :(得分:0)

I don't know how to avoid hard-coding of application type name and other things but you can try something like this in your controller

[HttpGet("{id:int}")]
public async Task<srting> Get(int id)
{
    var fabricClient = new FabricClient();
    string applicationTypeName = "ApplicationTypeName";
    string applicationVersion = "1.0.0";
    string actorServiceManifestName = "Actor1Pkg";
    var appManifest = await fabricClient.ServiceManager.GetServiceManifestAsync(applicationTypeName, applicationVersion, actorServiceManifestName);

    var document = XDocument.Parse(appManifest);
    ...
    // TODO: Get DefaultService Name attribute from simple XML
}

You will get an xml, then find the desired attribute