Pet*_*Lea 1 c# azure-service-fabric
对于我们的新项目,我们必须支持多租户方案.建议每个租户拥有一个应用程序是最安全的模型,因此我们将我们的应用程序逻辑分离为SystemApps和TenantApps
租户服务应通过(内部)访问的地方
织物:/ TenantApps_ {tenantId}/SomeTenantSvc
我们打算使用一个System服务来创建和删除客户端应用程序并检查它们的健康状况.这些应用程序将具有默认服务,该服务依次根据订阅启动/停止其应用程序中的其他服务.
理论上都很好,但我不能为我的生活找到从代码创建新应用程序和服务的位置.我假设它与FabricRuntime有关 - 但更精细的细节让我无法理解.
如果有人能够提供示例或链接到正确的文档,那么我将不胜感激.
小智 5
这是文档.
这是使用现有应用程序类型在代码中创建应用程序实例的方法:
string appName = "fabric:/MyApplication";
string appType = "MyApplicationType";
string appVersion = "1.0.0";
var fabricClient = new FabricClient();
// Create the application instance.
try
{
ApplicationDescription appDesc = new ApplicationDescription(new Uri(appName), appType, appVersion);
await fabricClient.ApplicationManager.CreateApplicationAsync(appDesc);
}
catch (AggregateException ae)
{
}
Run Code Online (Sandbox Code Playgroud)
对于服务:
// Create the stateless service description. For stateful services, use a StatefulServiceDescription object.
StatelessServiceDescription serviceDescription = new StatelessServiceDescription();
serviceDescription.ApplicationName = new Uri(appName);
serviceDescription.InstanceCount = 1;
serviceDescription.PartitionSchemeDescription = new SingletonPartitionSchemeDescription();
serviceDescription.ServiceName = new Uri(serviceName);
serviceDescription.ServiceTypeName = serviceType;
// Create the service instance. If the service is declared as a default service in the ApplicationManifest.xml,
// the service instance is already running and this call will fail.
try
{
await fabricClient.ServiceManager.CreateServiceAsync(serviceDescription);
}
catch (AggregateException ae)
{}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
749 次 |
最近记录: |