简体   繁体   English

如何从Visual Studio将应用程序的多个实例发布到Service Fabric群集?

[英]How do I publish multiple instances of an application to Service Fabric cluster from Visual Studio?

I have created a statless service fabric application in visual studio and need to publish two instances of it. 我已经在Visual Studio中创建了一个无状态服务结构应用程序,需要发布它的两个实例。 The first goes well, but when i try to pusblish the second app i get the error: 第一个运行良好,但是当我尝试使用第二个应用程序时,出现错误:

2>Application Type  DevelopmentType  and Version  1.0.0  was already registered with Cluster, unregistering it...
2>Unregister-ServiceFabricApplicationType : Application type and version is still in use
2>At C:\Program Files\Microsoft SDKs\Service 
2>Fabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:224 char:20
2>+             $reg | Unregister-ServiceFabricApplicationType -Force
2>+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2>    + CategoryInfo          : InvalidOperation: (Microsoft.Servi...usterConnection:ClusterConnection) [Unregister-Serv 
2>   iceFabricApplicationType], FabricException
2>    + FullyQualifiedErrorId : UnregisterApplicationTypeErrorId,Microsoft.ServiceFabric.Powershell.UnregisterApplicatio 
2>   nType
2> 
2>Finished executing script 'Deploy-FabricApplication.ps1'.

I want the instance to have the same ApplicationType, but when i publish with a new application name and a new publish profile i only get the error above. 我希望实例具有相同的ApplicationType,但是当我使用新的应用程序名称和新的发布配置文件进行发布时,我只会遇到上述错误。

The problem is that you're essentially trying to overwrite the existing app type with a new one but since the existing app type has an app associated with it, you get this error. 问题是您实际上是在尝试用新的应用程序类型覆盖现有的应用程序类型,但是由于现有的应用程序类型具有与之关联的应用程序,因此会出现此错误。 In order to "overwrite" the app type, the system would need to delete it and register the new one. 为了“覆盖”该应用程序类型,系统需要将其删除并注册新的应用程序类型。 But it can't be deleted because it has an existing app associated with it. 但是无法删除,因为它具有与之关联的现有应用程序。 So that's why you get this error. 因此,这就是您收到此错误的原因。

A little background on the difference between an application type and an application. 关于应用程序类型和应用程序之间差异的一些背景知识。 It's sort of like the difference between a class and an instance in programming. 这有点像编程中类和实例之间的区别。 An app type represents what an app can be. 应用类型表示应用可以是什么。 It contains the code, configuration, and data. 它包含代码,配置和数据。 But an app type is just a definition; 但是,应用程序类型只是一个定义; it's not a running app. 它不是正在运行的应用程序。 When you create an app, you create it to be based on an app type. 创建应用程序时,将其创建为基于应用程序类型。 Now you've got a running application. 现在您有了一个正在运行的应用程序。 Just like the programming analogy, you can create multiple applications from one app type, which is what you're trying to do. 就像编程类比一样,您可以从一种应用程序类型创建多个应用程序,这就是您要尝试做的。

When you deploy from VS, it doesn't know your intention that you want to create a new application from an existing app type on the cluster. 当您从VS进行部署时,您并不打算要从群集上的现有应用程序类型创建新应用程序。 It assumes you want to deploy the application with the code that you've defined in your project. 假设您要使用您在项目中定义的代码来部署应用程序。 Since VS doesn't know how that code differs from what is on the cluster, it proceeds with attempting to remove any conflicting app type (an app type with the same name and version) in order to register a new app type with the code that was contained in your project. 由于VS不知道该代码与集群上的代码有何不同,因此它会继续尝试删除任何冲突的应用程序类型(名称和版本相同的应用程序类型),以便使用以下代码注册新的应用程序类型:已包含在您的项目中。 And that's when you run into the error. 那就是您遇到错误的时候。

So how do you resolve this? 那么您如何解决呢? If your intention is really to just create another application from the existing app type, without any code differences between the two applications, then you'll need to handle this directly from PowerShell and not use VS. 如果您的意图实际上是根据现有应用程序类型创建另一个应用程序,而这两个应用程序之间没有任何代码差异,那么您将需要直接从PowerShell处理而不使用VS。 What you're trying to do is just basic management of your cluster. 您正在尝试做的只是集群的基本管理。 You'll want to use the New-ServiceFabricApplication PowerShell cmdlet (see https://docs.microsoft.com/en-us/powershell/servicefabric/vlatest/new-servicefabricapplication ). 您将要使用New-ServiceFabricApplication PowerShell cmdlet(请参阅https://docs.microsoft.com/zh-cn/powershell/servicefabric/vlatest/new-servicefabricapplication )。 Note that if you haven't configuration your application properly, you may run into port conflicts between the two applications. 请注意,如果您没有正确配置应用程序,则可能会在两个应用程序之间发生端口冲突。 To avoid that, you'd want to parameterize your ports in your app manifest so that you can provide different port values when invoking New-ServiceFabricApplication . 为避免这种情况,您需要在应用清单中对端口进行参数化,以便在调用New-ServiceFabricApplication时可以提供不同的端口值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让 Visual Studio 将应用程序发布到由证书公用名而不是指纹保护的 Service Fabric 群集? - How to Get Visual Studio to Publish an Application to Service Fabric Cluster Secured by Certificate Common Name Instead of Thumbprint? 从Visual Studio发布到受保护的群集错误 - Publish from Visual Studio to secured cluster error Service Fabric中不提供Service Fabric应用程序模板 - Service Fabric Application template not available in Visual Studio 如何使用Visual Studio在C#应用程序中发布Access数据库? - How do I publish an Access database with my C# application using Visual Studio? Visual Studio如何发布使用在线数据库中数据的应用程序 - Visual Studio How to Publish Application that uses data from an Online Database 我如何在本地开发Visual Studio网站然后发布 - How do I develop a visual studio web locally then publish it 如何在Visual Studio生成的发布配置文件中设置环境 - How do I set the environment in a Visual Studio generated publish profile 如何将本地github存储库发布到Visual Studio Services? - How do I publish a local github repo to Visual Studio Services? 如何单独发布我的 Visual Studio 项目 - How do I publish my visual studio project as a stand alone Visual Studio:发布应用程序 - Visual Studio: Publish application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM