我正在尝试向我的本地 Service Fabric 注册一个小型测试容器应用程序。
我可以使用 Copy-ServiceFabricApplicationPackage 将应用程序包复制到映像存储中,但是一旦我尝试使用 Register-ServiceFabricApplicationType 注册应用程序,就会收到以下错误:
Register-ServiceFabricApplicationType : Exception while parsing XML file:
C:\SfDevCluster\Data\ImageBuilderProxy\AppType\1e52a632-c74a-4afa-8a93-
022bc858e7b3\ReverseSvcPkg\ServiceManifest.xml
FileName:
C:\SfDevCluster\Data\ImageBuilderProxy\AppType\1e52a632-c74a-4afa-8a93-
022bc858e7b3\ReverseSvcPkg\ServiceManifest.xml
--> InvalidOperationException: There is an error in XML document (20, 56). --
> XmlSchemaValidationException: The
element 'EnvironmentVariables' in namespace
'http://schemas.microsoft.com/2011/01/fabric' cannot contain text. List of
possible elements expected: 'EnvironmentVariable' in namespace
'http://schemas.microsoft.com/2011/01/fabric'.
At line:1 char:1
+ Register-ServiceFabricApplicationType myapp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation:
(Microsoft.Servi...usterConnection:ClusterConnection) [Register-Servic
eFabricApplicationType], FabricException
+ FullyQualifiedErrorId :
RegisterApplicationTypeErrorId, Microsoft.ServiceFabric.Powershell.RegisterApplicationType
ApplicationManifest.xml 文件如下:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="myappType" ApplicationTypeVersion="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="MySvcSvcPkg" ServiceManifestVersion="1.0.0" />
<Policies>
<ContainerHostPolicies CodePackageRef="Code">
<PortBinding ContainerPort="9191" EndpointRef="MySvcSvcEndpoint"/>
</ContainerHostPolicies>
</Policies>
</ServiceManifestImport>
<DefaultServices>
<Service Name="ReversSvc">
<StatelessService ServiceTypeName="MySvcSvcType" InstanceCount="1">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
ServiceManifest.xml 如下:
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="MySvcSvcPkg" Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<ServiceTypes>
<StatelessServiceType ServiceTypeName="MySvcSvcType" UseImplicitHost="true">
</StatelessServiceType>
</ServiceTypes>
<CodePackage Name="code" Version="1.0.0">
<EntryPoint>
<ContainerHost>
<ImageName>xxxxxxxxxxx/MySvc:latest</ImageName>
<Commands></Commands>
</ContainerHost>
</EntryPoint>
<EnvironmentVariables>
<EnvironmentVariable Name="PORT" Value="9191"/>
</EnvironmentVariables>
</CodePackage>
<Resources>
<Endpoints>
<Endpoint Name="MySvcSvcEndpoint" UriScheme="http" Port="9191" Protocol="http"/>
</Endpoints>
</Resources>
</ServiceManifest>
据我所知,这符合规范,所以我不知道为什么会出现错误。