Sea*_*man 3 azure-service-fabric
如何在运行时获取正在执行的Service Fabric服务(和应用程序)版本?我已经尝试了下,但两者StatefulServiceContext并StatelessServiceContext没有提供这些信息.
您可以使用它FabricClient来获取此信息.
对于应用程序版本:
var applicationName = new Uri("fabric:/MyApp"); // or use Context.CodePackageActivationContext.ApplicationName
using (var client = new FabricClient())
{
var applications = await client.QueryManager.GetApplicationListAsync(applicationName).ConfigureAwait(false);
var version = applications[0].ApplicationTypeVersion;
}
Run Code Online (Sandbox Code Playgroud)
对于服务版本 -
从服务类中:
Context.CodePackageActivationContext.GetServiceManifestVersion()
Run Code Online (Sandbox Code Playgroud)
要么:
var serviceName = new Uri("fabric:/MyApp/MyService"); // or use Context.ServiceName
using (var client = new FabricClient())
{
var services = await client.QueryManager.GetServiceListAsync(applicationName, serviceName).ConfigureAwait(false);
var version = services[0].ServiceManifestVersion;
}
Run Code Online (Sandbox Code Playgroud)
笔记:
FabricClient.ApplicationManager.GetApplicationUpgradeProgressAsync并重新启动TargetApplicationTypeVersionFabricClient如果您经常使用它,可能需要缓存(请参阅此处的备注)CodePackageActivationContext还包含CodePackageVersion,这是比服务清单版本不同| 归档时间: |
|
| 查看次数: |
1490 次 |
| 最近记录: |