Azure service fabric 服务结构指定结构url
是否可以定义服务使用的url而不是标准的Azure service fabric 服务结构指定结构url,azure-service-fabric,Azure Service Fabric,是否可以定义服务使用的url而不是标准的结构:/AppName/ServiceName 我找不到这在应用程序级别上是否可配置。您可以从以下位置使用此uri生成器(ServiceUriBuilder.cs)类: 对于无状态服务,您可以轻松获得代理: var serviceUri = new ServiceUriBuilder(ServiceName); var proxyFactory = new ServiceProxyFactory(); var svc = proxyFactory.Crea
结构:/AppName/ServiceName
我找不到这在应用程序级别上是否可配置。您可以从以下位置使用此uri生成器(ServiceUriBuilder.cs)类: 对于无状态服务,您可以轻松获得代理:
var serviceUri = new ServiceUriBuilder(ServiceName);
var proxyFactory = new ServiceProxyFactory();
var svc = proxyFactory.CreateServiceProxy<IServiceName>(serviceUri.ToUri());
var serviceUri=新的ServiceUriBuilder(ServiceName);
var proxyFactory=新服务proxyFactory();
var svc=proxyFactory.CreateServiceProxy(serviceUri.ToUri());
对于有状态服务,必须指定分区
var serviceUri = new ServiceUriBuilder(StatefulServiceName);
var proxyFactory = new ServiceProxyFactory();
//this is just a sample of partition 1 if you are using number partitioning.
var partition = new ServicePartitionKey(1);
var svc = proxyFactory.CreateServiceProxy<IStatefulServiceName>(serviceUri.ToUri(), partition);
var-serviceUri=new-ServiceUriBuilder(StatefulServiceName);
var proxyFactory=新服务proxyFactory();
//如果您使用数字分区,这只是分区1的一个示例。
var partition=newservicepartitionkey(1);
var svc=proxyFactory.CreateServiceProxy(serviceUri.ToUri(),分区);
是,您可以将ApplicationManifest.xml
中的服务名称更改为其他名称,而不是取自服务类名的名称
Short:只需将该服务的ApplicationManifest.xml
中的name
属性更改为其他属性即可
在代码中:如果我有此服务:
公共接口ijustAnotherStateless服务:iSeries设备
{
任务SayHelloAsync(字符串someValue);
}
内部密封类JustAnotherStatelessService:StatelessService,IJustAnotherStatelessService
{
//服务实现
}
在Program.cs中注册如下:
ServiceRuntime.RegisterServiceAsync(“Justanother无状态服务类型”,
context=>new JustAnotherStatelessService(context)).GetAwaiter().GetResult();
并在该服务的servicemifest.xml
中
...
在ApplicationManifest.xml
中,您将获得建议的名称:
这将为您的服务提供一个Uri,如
fabric:/app\u name/justanother无状态服务
现在,继续并更改应用程序清单中的名称:
您的服务现在符合以下要求:
fabric:/app\u name/AwesomeService
谢谢您的回复,我想我不清楚我的要求。我想知道您是否可以让应用程序侦听fabric:/foobarbazservice
,但我认为这是不可能的,因为服务解析程序在应用程序类型中查找服务类型,不能(比如)随机选择一个!不,在这一部分您是对的,您仅限于url的{applicationName}/{serviceName\u set\u in_ApplicationManifest}方案。考虑到fabric transport内部构建Url的方式,我看不到任何设置完全自定义Url的方法。