CodePackage activation.Container 无法为图像启动期间出现错误

There was an error during CodePackage activation.Container failed to start for image

我已经从 4.7.2-windowsservercore-ltsc2016 为 ASP.net MVC 应用程序创建了一个图像,当我 运行 在本地使用 Docker 容器时,一切正常。我在 Azure 中设置了一个 5 节点 Fabric 集群,当我最初尝试部署时,我得到:

Error event: SourceId='System.FM', Property='State'.
Partition is below target replica or instance count.
fabric:/xx/yy -1 1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  (Showing 0 out of 0 replicas. Total available replicas: 0)

For more information see: http://aka.ms/sfhealth

当我查看各个节点时,我看到:

Error event: SourceId='System.Hosting', Property='Download:1.0:1.0'.
There was an error during download

一段时间后,节点中的健康事件发生变化并显示:

The ServicePackage was activated successfully.

然后

System.Hosting | CodePackageActivation:Code:EntryPoint

There was an error during CodePackage activation.Container failed to start for image:myrepo.azurecr.io/repo:1.0.0. failed to create endpoint sf-0-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx on network nat: HNS failed with error : The object already exists.

然后

There was an error during CodePackage activation.The service host terminated with exit code:7148

然后

The ServiceType was unregistered on the node since the Runtime or ApplicationHost closed.

我的服务清单有一个存储在 Azure CR 中的完整图像名称:

<ImageName>myrepo.azurecr.io/repo:1.0.0</ImageName>

还在我的应用程序清单中我有存储库凭据:

<RepositoryCredentials AccountName="myrepo" Password="xxxxxxxxxxxxxxxxxxxxxxxx" PasswordEncrypted="false"/>

我很乐意提供更多 details/logs,请告诉我从哪里获取它们。

编辑:

服务清单:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="mymvcPkg"
                 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="mymvcType" UseImplicitHost="true" />
  </ServiceTypes>
  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ContainerHost>
        <ImageName>myrepo.azurecr.io/repo:1.0.0</ImageName>
      </ContainerHost>
    </EntryPoint>    
  </CodePackage>
  <ConfigPackage Name="Config" Version="1.0.0" />
  <Resources>
    <Endpoints>
      <Endpoint Name="mymvcTypeEndpoint" UriScheme="http" Port="80" Protocol="http" />
    </Endpoints>
  </Resources>
</ServiceManifest>

应用清单:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="MvcType"
                     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">
  <Parameters>
    <Parameter Name="mymvc_InstanceCount" DefaultValue="-1" />
  </Parameters>  
  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="mymvcPkg" ServiceManifestVersion="1.0.0" />
    <ConfigOverrides />
    <Policies>
      <ContainerHostPolicies CodePackageRef="Code">
        <RepositoryCredentials AccountName="myrepo" Password="xxxxxxxxxxxxx" PasswordEncrypted="false"/>
        <PortBinding ContainerPort="80" EndpointRef="mymvcTypeEndpoint"/>
      </ContainerHostPolicies>
    </Policies>
  </ServiceManifestImport>
  <DefaultServices>    
    <Service Name="mymvc" ServicePackageActivationMode="ExclusiveProcess">
      <StatelessService ServiceTypeName="mymvcType" InstanceCount="[mymvc_InstanceCount]">
        <SingletonPartition />
      </StatelessService>
    </Service>
  </DefaultServices>
</ApplicationManifest>

我遇到的问题是我在集群中用于虚拟机(节点)的实例类型。 Azure 支持在他们的一些日志中发现错误:

System.ComponentModel.Win32Exception (0x80004005): Not enough storage is available to process this command

切换到更强大的实例解决了这个问题。微软声明:

The minimum supported use VM SKU is Standard D1 or Standard D1_V2 or equivalent with a minimum of 14 GB of local SSD

尽管我一直在尝试将 VM 配置为 20GB,但它们无法正常工作。目前我正在对 SKU A2 进行 运行 测试,到目前为止似乎工作正常。微软还表示:

• Partial core VM SKUs like Standard A0 are not supported for production workloads

• Standard A1 SKU is not supported for production workloads for performance reasons.

考虑到以上情况,D1_V2(3.5GB RAM,50GB SSD)可能是最便宜的可行选择。