Reliable Services 应用程序和服务清单示例Reliable services application and service manifest examples

下面是包含 ASP.NET Core Web 前端和有状态后端的 Service Fabric 应用程序的应用程序和服务清单示例。The following are examples of the application and service manifests for a Service Fabric application with an ASP.NET Core web front-end and a stateful back-end. 这些示例的用途是展示有哪些设置可用以及如何使用它们。The purpose of these examples is to show what settings are available and how to use them. 这些应用程序和服务清单基于 Service Fabric .NET 快速入门清单。These application and service manifests are based on the Service Fabric .NET Quickstart manifests.

展示了以下功能:The following features are shown:

清单Manifest 功能Features
应用程序清单Application manifest 资源监管以本地管理员帐户运行服务将默认策略应用到所有服务代码包创建用户和组主体、在服务实例之间共享数据包、重写服务终结点resource governance, run a service as a local admin account, apply a default policy to all service code packages, create user and group principals, share a data package between service instances, override service endpoints
FrontEndService 服务清单FrontEndService service manifest 服务启动时运行脚本定义 HTTPS 终结点Run a script at service startup, define an HTTPS endpoint
BackEndService 服务清单BackEndService service manifest 声明配置包声明数据包配置终结点Declare a config package, declare a data package, configure an endpoint

有关特定 XML 元素的详细信息,请参阅应用程序清单元素VotingWeb 服务清单元素VotingData 服务清单元素See Application manifest elements, VotingWeb service manifest elements, and VotingData service manifest elements for more information on specific XML elements.

应用程序清单Application manifest

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="VotingType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <Parameters>
    <Parameter Name="VotingData_MinReplicaSetSize" DefaultValue="3" />
    <Parameter Name="VotingData_PartitionCount" DefaultValue="1" />
    <Parameter Name="VotingData_TargetReplicaSetSize" DefaultValue="3" />
    <Parameter Name="VotingWeb_InstanceCount" DefaultValue="-1" />
    <Parameter Name="CpuCores" DefaultValue="2" />
    <Parameter Name="Memory" DefaultValue="4084" />
    <Parameter Name="BlockIOWeight" DefaultValue="200" />
    <Parameter Name="MaximumIOBandwidth" DefaultValue="1024" />
    <Parameter Name="MemoryReservationInMB" DefaultValue="1024" />
    <Parameter Name="MemorySwapInMB" DefaultValue="4084"/>
    <Parameter Name="Port" DefaultValue="8081" />
    <Parameter Name="Protocol" DefaultValue="tcp" />
    <Parameter Name="Type" DefaultValue="internal" />
  </Parameters>
  <!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion 
       should match the Name and Version attributes of the ServiceManifest element defined in the 
       ServiceManifest.xml file. -->
  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="VotingDataPkg" ServiceManifestVersion="1.0.0" />
    <!-- Override endpoints declared in the service manifest. -->
    <ResourceOverrides>
      <Endpoints>
        <Endpoint Name="DataEndpoint" Port="[Port]" Protocol="[Protocol]" Type="[Type]" />
      </Endpoints>
    </ResourceOverrides>

    <!-- Policies to be applied to the imported service manifest. -->
    <Policies>

      <!-- Set resource governance at the service package level. -->
      <ServicePackageResourceGovernancePolicy CpuCores="[CpuCores]" MemoryInMB="[Memory]"/>

      <!-- Set resource governance at the code package level. -->
      <ResourceGovernancePolicy CodePackageRef="Code" CpuPercent="10" MemoryInMB="[Memory]" BlockIOWeight="[BlockIOWeight]" 
                                MaximumIOBandwidth="[MaximumIOBandwidth]" MaximumIOps="[MaximumIOps]" MemoryReservationInMB="[MemoryReservationInMB]" 
                                MemorySwapInMB="[MemorySwapInMB]"/>

      <!-- Share the data package across multiple instances of the VotingData service-->
      <PackageSharingPolicy PackageRef="Data"/>

      <!-- Give read rights on the "DataEndpoint" endpoint to the Customer2 account.-->
      <SecurityAccessPolicy GrantRights="Read" PrincipalRef="Customer2" ResourceRef="DataEndpoint" ResourceType="Endpoint"/>         
    </Policies>
  </ServiceManifestImport>

  <!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion 
       should match the Name and Version attributes of the ServiceManifest element defined in the 
       ServiceManifest.xml file. -->
  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="VotingWebPkg" ServiceManifestVersion="1.0.0" />

    <!-- Policies to be applied to the imported service manifest. -->
    <Policies>
      <!-- Run the setup entry point (defined in the imported service manifest) as the SetupAdminUser account 
      (declared in the following Principals section). -->
      <RunAsPolicy CodePackageRef="Code" UserRef="SetupAdminUser" EntryPointType="Setup" />

    </Policies>

  </ServiceManifestImport>
  <DefaultServices>
    <!-- The section below creates instances of service types, when an instance of this 
         application type is created. You can also create one or more instances of service type using the 
         ServiceFabric PowerShell module.

         The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
    <Service Name="VotingData">
      <StatefulService ServiceTypeName="VotingDataType" TargetReplicaSetSize="[VotingData_TargetReplicaSetSize]" MinReplicaSetSize="[VotingData_MinReplicaSetSize]">
        <UniformInt64Partition PartitionCount="[VotingData_PartitionCount]" LowKey="0" HighKey="25" />
      </StatefulService>
    </Service>
    <Service Name="VotingWeb" ServicePackageActivationMode="ExclusiveProcess">
      <StatelessService ServiceTypeName="VotingWebType" InstanceCount="[VotingWeb_InstanceCount]">
        <SingletonPartition />
      </StatelessService>
    </Service>
  </DefaultServices>
  <!-- Define users and groups required to run the services and access resources.  Principals are used in the Policies section(s). -->
  <Principals>
    <!-- Declare a set of groups as security principals, which can be referenced in policies. Groups are useful if there are multiple users 
    for different service entry points and they need to have certain common privileges that are available at the group level. -->
    <Groups>
      <!-- Create a group that has administrator privileges. -->
      <Group Name="LocalAdminGroup">
        <Membership>
          <SystemGroup Name="Administrators" />
        </Membership>
      </Group>
    </Groups>
    <Users>
      <!-- Declare a user and add the user to the Administrators system group. The SetupAdminUser account is used to run the 
      setup entry point of the VotingWebPkg code package (described in the preceding Policies section).-->
      <User Name="SetupAdminUser">
        <MemberOf>
          <SystemGroup Name="Administrators" />
        </MemberOf>
      </User>
      <!-- Create a user. Local user accounts are created on the machines where the application is deployed. By default, these accounts 
      do not have the same names as those specified here. Instead, they are dynamically generated and have random passwords. -->
      <User Name="Customer1" >
        <MemberOf>
          <!-- Add the user to the local administrators group.-->
          <Group NameRef="LocalAdminGroup" />
        </MemberOf>
      </User>
      <!-- Create a user as a local user with the specified account name and password. Local user accounts are created on the machines 
      where the application is deployed. -->
      <User Name="Customer2" AccountType="LocalUser" AccountName="Customer1" Password="MyPassword">
        <MemberOf>
          <!-- Add the user to the local administrators group.-->
          <Group NameRef="LocalAdminGroup" />
        </MemberOf>
      </User>
      <!-- Create a user as NetworkService. -->
      <User Name="MyDefaultAccount" AccountType="NetworkService" />      
    </Users>
  </Principals>
  <!-- Policies applied at the application level. -->
  <Policies>
    <!-- Specify a default user account for all code packages that don't have a specific RunAsPolicy defined in 
    the ServiceManifestImport section(s). -->
    <DefaultRunAsPolicy UserRef="MyDefaultAccount" />

  </Policies>
</ApplicationManifest>

VotingWeb 服务清单VotingWeb service manifest

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="VotingWebPkg"
                 Version="1.0.0"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="https://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <!-- This is the name of your ServiceType. 
         This name must match the string used in RegisterServiceType call in Program.cs. -->
    <StatelessServiceType ServiceTypeName="VotingWebType" />
  </ServiceTypes>

  <!-- Code package is your service executable. -->
  <CodePackage Name="Code" Version="1.0.0">
    <!-- A privileged entry point that by default runs with the same credentials as Service Fabric (typically the NetworkService account) before 
    any other entry point. Use the setup entry point to set system environment variables, give the account running the service (NETWORK SERVICE, by default) 
    access to a certificate's private key, or perform other setup tasks. In the application manifest, you can change the security permissions to run the startup script 
    under a local system account or an administrator account.  -->
    <SetupEntryPoint>
      <ExeHost>
        <!-- The setup script to run. -->
        <Program>Setup.bat</Program>
        <!-- Pass arguments to the script when it runs.-->
        <Arguments>MyValue</Arguments>
        <!-- The working directory for the process in the code package on the node where the application is deployed. CodePackage sets the working directory to be 
        the root of the code package regardless of where the EXE is defined in the code package directory. This is where the processes can write the data. Writing data 
        in the code package or code base is not recommended as those folders could be shared between different application instances and may get deleted.-->
        <WorkingFolder>CodePackage</WorkingFolder>
        <!-- Warning! Do not use console redirection in a production application, only use it for local development and debugging. Redirects console output from the startup
        script to an output file in the application folder called "log" on the cluster node where the application is deployed and run. Also set the number of output files
        to retain and the maximum file size (in KB). -->
        <ConsoleRedirection FileRetentionCount="10" FileMaxSizeInKb="20480"/>
      </ExeHost>
    </SetupEntryPoint>
    <EntryPoint>
      <ExeHost>
        <Program>VotingWeb.exe</Program>
        <!-- The working directory for the process in the code package on the node where the application is deployed. CodePackage sets the working directory to be 
        the root of the code package regardless of where the EXE is defined in the code package directory. This is where the processes can write the data. Writing data 
        in the code package or code base is not recommended as those folders could be shared between different application instances and may get deleted.-->
        <WorkingFolder>CodePackage</WorkingFolder>
      </ExeHost>
    </EntryPoint>
  </CodePackage>

  <!-- Config package is the contents of the Config directory under PackageRoot that contains an 
       independently-updateable and versioned set of custom configuration settings for your service. -->
  <ConfigPackage Name="Config" Version="1.0.0" />

  <Resources>
    <Endpoints>
      <!-- Configure a HTTPS endpoint on port 443. This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Protocol="https" Name="EndpointHttps" Type="Input" Port="443" />
    </Endpoints>
  </Resources>
</ServiceManifest>

VotingData 服务清单VotingData service manifest

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="VotingDataPkg"
                 Version="1.0.0"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="https://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <!-- This is the name of your ServiceType. 
         This name must match the string used in RegisterServiceType call in Program.cs. -->
    <StatefulServiceType ServiceTypeName="VotingDataType"  HasPersistedState="true" />
  </ServiceTypes>

  <!-- Code package is your service executable. -->
  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>VotingData.exe</Program>
        <!-- The working directory for the process in the code package on the node where the application is deployed. CodePackage sets the working directory to be 
        the root of the code package regardless of where the EXE is defined in the code package directory. This is where the processes can write the data. Writing data 
        in the code package or code base is not recommended as those folders could be shared between different application instances and may get deleted.-->
        <WorkingFolder>CodePackage</WorkingFolder>
      </ExeHost>
    </EntryPoint>
  </CodePackage>

  <!-- Declares a folder, named by the Name attribute, under PackageRoot that contains a Settings.xml file. This file contains sections of user-defined, 
  key-value pair settings that the process can read back at run time. During an upgrade, if only the ConfigPackage version has changed, 
  then the running process is not restarted. Instead, a callback notifies the process that configuration settings have changed so they can be reloaded dynamically. -->
  <ConfigPackage Name="Config" Version="1.0.0" />

  <!-- Declares a folder, named by the Name attribute, under PackageRoot which contains static data files to be consumed by the process at run time. -->
  <DataPackage Name="Data" Version="1.0.0"/>

  <Resources>
    <Endpoints>
      <!-- Define an internal (used for intra-application communication) TCP endpoint. Since no port is specified, one is created and assigned dynamically
           to the service.-->
      <Endpoint Name="DataEndpoint" Protocol="tcp" Type="Internal" />
    </Endpoints>
  </Resources>

</ServiceManifest>

应用程序清单元素Application manifest elements

ApplicationManifest 元素ApplicationManifest Element

以声明方式描述应用程序类型和版本。Declaratively describes the application type and version. 引用构成服务的一个或多个服务清单来撰写应用程序类型。One or more service manifests of the constituent services are referenced to compose an application type. 可以使用参数化应用程序设置重写构成服务的配置设置。Configuration settings of the constituent services can be overridden using parameterized application settings. 默认服务、服务模板、主体、策略、诊断设置和证书也可以在应用程序级别声明。Default services, service templates, principals, policies, diagnostics set-up, and certificates can also declared at the application level. 有关详细信息,请参阅 ApplicationManifest 元素For more information, see ApplicationManifest Element

Parameters 元素Parameters Element

声明在此应用程序清单中使用的参数。Declares the parameters that are used in this application manifest. 当应用程序已实例化并可用于重写应用程序或服务配置设置时,可以提供这些参数的值。The value of these parameters can be supplied when the application is instantiated and can be used to override application or service configuration settings. 有关详细信息,请参阅 Parameters 元素For more information, see Parameters Element

Parameter 元素Parameter Element

要在此清单中使用的应用程序参数。An application parameter to be used in this manifest. 可在应用程序实例化期间更改参数值;如果未提供值,则使用默认值。The parameter value can be changed during application instantiation, or, if no value is supplied the default value is used. 有关详细信息,请参阅 Parameter 元素For more information, see Parameter Element

ServiceManifestImport 元素ServiceManifestImport Element

导入服务开发人员创建的服务清单。Imports a service manifest created by the service developer. 必须导入应用程序中每个构成服务的服务清单。A service manifest must be imported for each constituent service in the application. 可为服务清单声明配置重写和策略。Configuration overrides and policies can be declared for the service manifest. 有关详细信息,请参阅 ServiceManifestImport 元素For more information, see ServiceManifestImport Element

ServiceManifestRef 元素ServiceManifestRef Element

按引用导入服务清单。Imports the service manifest by reference. 当前,服务清单文件 (ServiceManifest.xml) 必须存在于生成包中。Currently the service manifest file (ServiceManifest.xml) must be present in the build package. 有关详细信息,请参阅 ServiceManifestRef 元素For more information, see ServiceManifestRef Element

ResourceOverrides 元素ResourceOverrides Element

指定服务清单资源中声明的终结点的资源重写。Specifies resource overrides for endpoints declared in service manifest resources. 有关详细信息,请参阅 ResourceOverrides 元素For more information, see ResourceOverrides Element

Endpoints 元素Endpoints Element

要重写的终结点。The endpoint(s) to override. 有关详细信息,请参阅 Endpoints 元素For more information, see Endpoints Element

Endpoint 元素Endpoint Element

服务清单中声明的要重写的终结点。The endpoint, declared in the service manifest, to override. 有关详细信息,请参阅 Endpoint 元素For more information, see Endpoint Element

Policies 元素Policies Element

描述要在导入的服务清单中应用的策略(终结点绑定、包共享、运行方式和安全访问权限)。Describes policies (end-point binding, package sharing, run-as, and security access) to be applied on the imported service manifest. 有关详细信息,请参阅 Policies 元素For more information, see Policies Element

ServicePackageResourceGovernancePolicy 元素ServicePackageResourceGovernancePolicy Element

定义在整个服务包级别应用的资源调控策略。Defines the resource governance policy that is applied at the level of the entire service package. 有关详细信息,请参阅 ServicePackageResourceGovernancePolicy 元素For more information, see ServicePackageResourceGovernancePolicy Element

ResourceGovernancePolicy 元素ResourceGovernancePolicy Element

指定代码包的资源限制。Specifies resource limits for a codepackage. 有关详细信息,请参阅 ResourceGovernancePolicy 元素For more information, see ResourceGovernancePolicy Element

PackageSharingPolicy 元素PackageSharingPolicy Element

指示是否应跨同一服务类型的服务实例共享某个代码、配置或数据包。Indicates if a code, config or data package should be shared across service instances of the same service type. 有关详细信息,请参阅 PackageSharingPolicy 元素For more information, see PackageSharingPolicy Element

SecurityAccessPolicy 元素SecurityAccessPolicy Element

向服务清单中定义的资源(例如终结点)上的主体授予访问权限。Grants access permissions to a principal on a resource (such as an endpoint) defined in a service manifest. 通常,它非常有助于控制和限制服务对不同资源的访问,以尽量降低安全风险。Typically, it is very useful to control and restrict access of services to different resources in order to minimize security risks. 从市场中由不同开发人员开发的服务集合构建应用程序时,此属性尤其重要。This is especially important when the application is built from a collection of services from a marketplace which are developed by different developers. 有关详细信息,请参阅 SecurityAccessPolicy 元素For more information, see SecurityAccessPolicy Element

RunAsPolicy 元素RunAsPolicy Element

指定运行服务代码包时所用的本地用户或本地系统帐户。Specifies the local user or local system account that a service code package will run as. 在 Azure Active Directory 是可用的 Windows Server 部署上支持域帐户。Domain accounts are supported on Windows Server deployments where Azure Active Directory is available. 默认情况下,应用程序在运行 Fabric.exe 程序的帐户之下运行。By default, applications run under the account that the Fabric.exe process runs under. 应用程序也可以以其他帐户运行,必须在 Principals 节中声明。Applications can also run as other accounts, which must be declared in the Principals section. 如果向服务应用 RunAs 策略务,而服务清单声明具有 HTTP 协议的终结点资源,则还必须指定 SecurityAccessPolicy,以确保分配给这些终结点的端口都已针对用来运行服务的 RunAs 用户帐户正确列入访问控制列表中。If you apply a RunAs policy to a service, and the service manifest declares endpoint resources with the HTTP protocol, you must also specify a SecurityAccessPolicy to ensure that ports allocated to these endpoints are correctly access-control listed for the RunAs user account that the service runs under. 对于 HTTPS 终结点,还必须定义 EndpointBindingPolicy,用于指示要返回给客户端的证书名称。For an HTTPS endpoint, you also have to define a EndpointBindingPolicy to indicate the name of the certificate to return to the client. 有关详细信息,请参阅 RunAsPolicy 元素For more information, see RunAsPolicy Element

DefaultServices 元素DefaultServices Element

声明每当一个应用程序依据此应用程序类型进行实例化时自动创建的服务实例。Declares service instances that are automatically created whenever an application is instantiated against this application type. 有关详细信息,请参阅 DefaultServices 元素For more information, see DefaultServices Element

Service 元素Service Element

声明在实例化应用程序时要自动创建的服务。Declares a service to be created automatically when the application is instantiated. 有关详细信息,请参阅 Service 元素For more information, see Service Element

StatefulService 元素StatefulService Element

定义有状态服务。Defines a stateful service. 有关详细信息,请参阅 StatefulService 元素For more information, see StatefulService Element

StatelessService 元素StatelessService Element

定义无状态服务。Defines a stateless service. 有关详细信息,请参阅 StatelessService 元素For more information, see StatelessService Element

Principals 元素Principals Element

描述此应用程序运行服务和安全资源所需的安全主体(用户、组)。Describes the security principals (users, groups) required for this application to run services and secure resources. 主体在 policies 节中引用。Principals are referenced in the policies sections. 有关详细信息,请参阅 Principals 元素For more information, see Principals Element

Groups 元素Groups Element

将组集声明为可在策略中引用的安全主体。Declares a set of groups as security principals, which can be referenced in policies. 如果不同的服务入口点对应有多个用户,而且这些用户需要拥有特定的常见组级别权限,则组就很有用。Groups are useful if there are multiple users for different service entry points and they need to have certain common privileges that are available at the group level. 有关详细信息,请参阅 Groups 元素For more information, see Groups Element

Group 元素Group Element

将组声明为可在策略中引用的安全主体。Declares a group as a security principal, which can be referenced in policies. 有关详细信息,请参阅 Group 元素For more information, see Group Element

Membership 元素Membership Element

有关详细信息,请参阅 Membership 元素For more information, see Membership Element

SystemGroup 元素SystemGroup Element

有关详细信息,请参阅 SystemGroup 元素For more information, see SystemGroup Element

Users 元素Users Element

将一组用户声明为可在策略中引用的安全主体。Declares a set of users as security principals, which can be referenced in policies. 有关详细信息,请参阅 Users 元素For more information, see Users Element

User 元素User Element

将用户声明为可在策略中引用的安全主体。Declares a user as a security principal, which can be referenced in policies. 有关详细信息,请参阅 User 元素For more information, see User Element

MemberOf 元素MemberOf Element

用户可以添加到任何现有的成员身份组中,因此它可以继承所有属性和该成员身份组的安全设置。Users can be added to any existing membership group, so it can inherit all the properties and security settings of that membership group. 成员身份组可用来保护需要按不同的服务或相同的服务(在不同计算机上)访问的外部资源。The membership group can be used to secure external resources that need to be accessed by different services or the same service (on a different machine). 有关详细信息,请参阅 MemberOf 元素For more information, see MemberOf Element

SystemGroup 元素SystemGroup Element

要将用户添加到的系统组。The system group to add the user to. 必须在 Groups 节中定义该系统组。The system group must be defined in the Groups section. 有关详细信息,请参阅 SystemGroup 元素For more information, see SystemGroup Element

Group 元素Group Element

要将用户添加到的组。The group to add the user to. 必须在 Groups 节中定义该组。The group must be defined in the Groups section. 有关详细信息,请参阅 Group 元素For more information, see Group Element

Policies 元素Policies Element

描述要在应用程序级别应用的策略(日志集合、默认运行方式帐户、运行状况和安全访问)。Describes the policies (log collection, default run-as, health, and security access) to be applied at the application level. 有关详细信息,请参阅 Policies 元素For more information, see Policies Element

DefaultRunAsPolicy 元素DefaultRunAsPolicy Element

针对在 ServiceManifestImport 节中未定义特定 RunAsPolicy 的所有服务代码包指定默认用户帐户。Specify a default user account for all service code packages that don't have a specific RunAsPolicy defined in the ServiceManifestImport section. 有关详细信息,请参阅 DefaultRunAsPolicy 元素For more information, see DefaultRunAsPolicy Element

VotingWeb 服务清单元素VotingWeb service manifest elements

ServiceManifest 元素ServiceManifest Element

以声明方式描述服务类型和版本。Declaratively describes the service type and version. 它列出组成一个服务包以支持一个或多个服务类型的独立可升级的代码、配置和数据包。It lists the independently upgradeable code, configuration, and data packages that together compose a service package to support one or more service types. 此外,还指定资源、诊断设置和服务元数据,例如服务类型、运行状况属性和负载均衡指标。Resources, diagnostics settings, and service metadata, such as service type, health properties, and load-balancing metrics, are also specified. 有关详细信息,请参阅 ServiceManifest 元素For more information, see ServiceManifest Element

ServiceTypes 元素ServiceTypes Element

定义此清单中的 CodePackage 支持哪些服务类型。Defines what service types are supported by a CodePackage in this manifest. 当一种服务针对这些服务类型之一进行实例化时,可激活此清单中声明的所有代码包,方法是运行这些代码包的入口点。When a service is instantiated against one of these service types, all code packages declared in this manifest are activated by running their entry points. 在清单级别而不是代码包级别声明服务类型。Service types are declared at the manifest level and not the code package level. 有关详细信息,请参阅 ServiceTypes 元素For more information, see ServiceTypes Element

StatelessServiceType 元素StatelessServiceType Element

描述无状态服务类型。Describes a stateless service type. 有关详细信息,请参阅 StatelessServiceType 元素For more information, see StatelessServiceType Element

CodePackage 元素CodePackage Element

描述支持定义的服务类型的代码包。Describes a code package that supports a defined service type. 当一种服务针对这些服务类型之一进行实例化时,可激活此清单中声明的所有代码包,方法是运行这些代码包的入口点。When a service is instantiated against one of these service types, all code packages declared in this manifest are activated by running their entry points. 生成的进程应在运行时注册所支持的服务类型。The resulting processes are expected to register the supported service types at run time. 当存在多个代码包时,每当系统查找任何一种声明的服务类型时,它们都会被激活。When there are multiple code packages, they are all activated whenever the system looks for any one of the declared service types. 有关详细信息,请参阅 CodePackage 元素For more information, see CodePackage Element

SetupEntryPoint 元素SetupEntryPoint Element

一个特权入口点,默认情况下,以与 Service Fabric(通常是 NETWORKSERVICE 帐户)相同的凭据先于任何其他入口点运行。A privileged entry point that by default runs with the same credentials as Service Fabric (typically the NETWORKSERVICE account) before any other entry point. EntryPoint 指定的可执行文件通常是长时间运行的服务主机。The executable specified by EntryPoint is typically the long-running service host. 提供单独的设置入口点可避免长时间使用高特权运行服务主机。The presence of a separate setup entry point avoids having to run the service host with high privileges for extended periods of time. 有关详细信息,请参阅 SetupEntryPoint 元素For more information, see SetupEntryPoint Element

ExeHost 元素ExeHost Element

有关详细信息,请参阅 ExeHost 元素For more information, see ExeHost Element

Program 元素Program Element

可执行文件名称。The executable name. 例如,“MySetup.bat”或“MyServiceHost.exe”。For example, "MySetup.bat" or "MyServiceHost.exe". 有关详细信息,请参阅 Program 元素For more information, see Program Element

Arguments 元素Arguments Element

有关详细信息,请参阅 Arguments 元素For more information, see Arguments Element

WorkingFolder 元素WorkingFolder Element

部署应用程序时所在群集节点上的代码包中的进程工作目录。The working directory for the process in the code package on the cluster node where the application is deployed. 可以指定三个值:Work(默认)、CodePackage 或 CodeBase。You can specify three values: Work (the default), CodePackage, or CodeBase. CodeBase 指定将工作目录设置为在代码包中定义 EXE 时所在的目录。CodeBase specifies that the working directory is set to the directory in which the EXE is defined in the code package. CodePackage 将工作目录设置为代码包的根目录,不管在代码包目录中定义 EXE 时的位置如何。CodePackage sets the working directory to be the root of the code package regardless of where the EXE is defined in the code package directory. Work 将工作目录设置为在节点上创建的唯一文件夹。Work sets the work directory to a unique folder created on the node. 整个应用程序实例的此文件夹是同一个文件夹。This folder is the same for the entire application instance. 默认情况下,应用程序中所有进程的工作目录设置为应用程序工作文件夹。By default, the working directory of all processes in the application is set to the application work folder. 这是允许进程写入数据的位置。This is where the processes can write the data. 建议不要在代码包或代码库中写入数据,因为这些文件夹可能是在不同的应用程序实例之间共享的,可能会被删除。Writing data in the code package or code base is not recommended as those folders could be shared between different application instances and may get deleted. 有关详细信息,请参阅 WorkingFolder 元素For more information, see WorkingFolder Element

ConsoleRedirection 元素ConsoleRedirection Element

警告

请勿在生产应用程序中使用控制台重定向,只能将其用于本地开发和调试。Do not use console redirection in a production application, only use it for local development and debugging. 请在部署和运行应用程序时所在的群集节点上,将控制台输出从启动脚本重定向到名为“log”的应用程序文件夹中的一个输出文件。Redirects console output from the startup script to an output file in the application folder called "log" on the cluster node where the application is deployed and run. 有关详细信息,请参阅 ConsoleRedirection 元素For more information, see ConsoleRedirection Element

EntryPoint 元素EntryPoint Element

EntryPoint 指定的可执行文件通常是长时间运行的服务主机。The executable specified by EntryPoint is typically the long-running service host. 提供单独的设置入口点可避免长时间使用高特权运行服务主机。The presence of a separate setup entry point avoids having to run the service host with high privileges for extended periods of time. 由 EntryPoint 指定的可执行文件在 SetupEntryPoint 成功退出后运行。The executable specified by EntryPoint is run after SetupEntryPoint exits successfully. 如果总是终止或出现故障,则将监视并重启所产生的过程(再次从 SetupEntryPoint 开始)。The resulting process is monitored and restarted (beginning again with SetupEntryPoint) if it ever terminates or crashes. 有关详细信息,请参阅 EntryPoint 元素For more information, see EntryPoint Element

ExeHost 元素ExeHost Element

有关详细信息,请参阅 ExeHost 元素For more information, see ExeHost Element

ConfigPackage 元素ConfigPackage Element

声明一个按 Name 特性命名的文件夹,该文件夹位于包含 Settings.xml 文件的 PackageRoot 中。Declares a folder, named by the Name attribute, under PackageRoot that contains a Settings.xml file. 此文件包含进程用户定义的键值对设置,进程可在运行时读回这些设置。This file contains sections of user-defined, key-value pair settings that the process can read back at run time. 升级期间,如果仅更改了 ConfigPackage 版本,则不重启正在运行的进程。During an upgrade, if only the ConfigPackage version has changed, then the running process is not restarted. 相反,回调会向进程通知配置设置已更改,以便可以重新动态加载这些设置。Instead, a callback notifies the process that configuration settings have changed so they can be reloaded dynamically. 有关详细信息,请参阅 ConfigPackage 元素For more information, see ConfigPackage Element

Resources 元素Resources Element

描述此服务使用的资源,可以在不修改已编译代码的情况下声明,并可以在部署服务时更改。Describes the resources used by this service, which can be declared without modifying compiled code and changed when the service is deployed. 通过应用程序清单的 Principals 和 Policies 节控制对这些资源的访问。Access to these resources is controlled through the Principals and Policies sections of the application manifest. 有关详细信息,请参阅 Resources 元素For more information, see Resources Element

Endpoints 元素Endpoints Element

定义服务的终结点。Defines endpoints for the service. 有关详细信息,请参阅 Endpoints 元素For more information, see Endpoints Element

Endpoint 元素Endpoint Element

服务清单中声明的要重写的终结点。The endpoint, declared in the service manifest, to override. 有关详细信息,请参阅 Endpoint 元素For more information, see Endpoint Element

VotingData 服务清单元素VotingData service manifest elements

ServiceManifest 元素ServiceManifest Element

以声明方式描述服务类型和版本。Declaratively describes the service type and version. 它列出组成一个服务包以支持一个或多个服务类型的独立可升级的代码、配置和数据包。It lists the independently upgradeable code, configuration, and data packages that together compose a service package to support one or more service types. 此外,还指定资源、诊断设置和服务元数据,例如服务类型、运行状况属性和负载均衡指标。Resources, diagnostics settings, and service metadata, such as service type, health properties, and load-balancing metrics, are also specified. 有关详细信息,请参阅 ServiceManifest 元素For more information, see ServiceManifest Element

ServiceTypes 元素ServiceTypes Element

定义此清单中的 CodePackage 支持哪些服务类型。Defines what service types are supported by a CodePackage in this manifest. 当一种服务针对这些服务类型之一进行实例化时,可激活此清单中声明的所有代码包,方法是运行这些代码包的入口点。When a service is instantiated against one of these service types, all code packages declared in this manifest are activated by running their entry points. 在清单级别而不是代码包级别声明服务类型。Service types are declared at the manifest level and not the code package level. 有关详细信息,请参阅 ServiceTypes 元素For more information, see ServiceTypes Element

StatefulServiceType 元素StatefulServiceType Element

描述有状态服务类型。Describes a stateful service type. 有关详细信息,请参阅 StatefulServiceType 元素For more information, see StatefulServiceType Element

CodePackage 元素CodePackage Element

描述支持定义的服务类型的代码包。Describes a code package that supports a defined service type. 当一种服务针对这些服务类型之一进行实例化时,可激活此清单中声明的所有代码包,方法是运行这些代码包的入口点。When a service is instantiated against one of these service types, all code packages declared in this manifest are activated by running their entry points. 生成的进程应在运行时注册所支持的服务类型。The resulting processes are expected to register the supported service types at run time. 当存在多个代码包时,每当系统查找任何一种声明的服务类型时,它们都会被激活。When there are multiple code packages, they are all activated whenever the system looks for any one of the declared service types. 有关详细信息,请参阅 CodePackage 元素For more information, see CodePackage Element

EntryPoint 元素EntryPoint Element

EntryPoint 指定的可执行文件通常是长时间运行的服务主机。The executable specified by EntryPoint is typically the long-running service host. 提供单独的设置入口点可避免长时间使用高特权运行服务主机。The presence of a separate setup entry point avoids having to run the service host with high privileges for extended periods of time. 由 EntryPoint 指定的可执行文件在 SetupEntryPoint 成功退出后运行。The executable specified by EntryPoint is run after SetupEntryPoint exits successfully. 如果总是终止或出现故障,则将监视并重启所产生的过程(再次从 SetupEntryPoint 开始)。The resulting process is monitored and restarted (beginning again with SetupEntryPoint) if it ever terminates or crashes. 有关详细信息,请参阅 EntryPoint 元素For more information, see EntryPoint Element

ExeHost 元素ExeHost Element

有关详细信息,请参阅 ExeHost 元素For more information, see ExeHost Element

Program 元素Program Element

可执行文件名称。The executable name. 例如,“MySetup.bat”或“MyServiceHost.exe”。For example, "MySetup.bat" or "MyServiceHost.exe". 有关详细信息,请参阅 Program 元素For more information, see Program Element

WorkingFolder 元素WorkingFolder Element

部署应用程序时所在群集节点上的代码包中的进程工作目录。The working directory for the process in the code package on the cluster node where the application is deployed. 可以指定三个值:Work(默认)、CodePackage 或 CodeBase。You can specify three values: Work (the default), CodePackage, or CodeBase. CodeBase 指定将工作目录设置为在代码包中定义 EXE 时所在的目录。CodeBase specifies that the working directory is set to the directory in which the EXE is defined in the code package. CodePackage 将工作目录设置为代码包的根目录,不管在代码包目录中定义 EXE 时的位置如何。CodePackage sets the working directory to be the root of the code package regardless of where the EXE is defined in the code package directory. Work 将工作目录设置为在节点上创建的唯一文件夹。Work sets the work directory to a unique folder created on the node. 整个应用程序实例的此文件夹是同一个文件夹。This folder is the same for the entire application instance. 默认情况下,应用程序中所有进程的工作目录设置为应用程序工作文件夹。By default, the working directory of all processes in the application is set to the application work folder. 这是允许进程写入数据的位置。This is where the processes can write the data. 建议不要在代码包或代码库中写入数据,因为这些文件夹可能是在不同的应用程序实例之间共享的,可能会被删除。Writing data in the code package or code base is not recommended as those folders could be shared between different application instances and may get deleted. 有关详细信息,请参阅 WorkingFolder 元素For more information, see WorkingFolder Element

ConfigPackage 元素ConfigPackage Element

声明一个按 Name 特性命名的文件夹,该文件夹位于包含 Settings.xml 文件的 PackageRoot 中。Declares a folder, named by the Name attribute, under PackageRoot that contains a Settings.xml file. 此文件包含进程用户定义的键值对设置,进程可在运行时读回这些设置。This file contains sections of user-defined, key-value pair settings that the process can read back at run time. 升级期间,如果仅更改了 ConfigPackage 版本,则不重启正在运行的进程。During an upgrade, if only the ConfigPackage version has changed, then the running process is not restarted. 相反,回调会向进程通知配置设置已更改,以便可以重新动态加载这些设置。Instead, a callback notifies the process that configuration settings have changed so they can be reloaded dynamically. 有关详细信息,请参阅 ConfigPackage 元素For more information, see ConfigPackage Element

DataPackage 元素DataPackage Element

声明一个按 Name 特性命名的文件夹,该文件夹位于将要由进程在运行时使用的静态数据文件所在的 PackageRoot 中。Declares a folder, named by the Name attribute, under PackageRoot which contains static data files to be consumed by the process at run time. 升级服务清单中所列的任何数据包时,Service Fabric 会回收主机和支持包中指定的所有 EXE 和 DLLHOST。Service Fabric will recycle all EXEs and DLLHOSTs specified in the host and support packages when any of the data packages listed in the service manifest are upgraded. 有关详细信息,请参阅 DataPackage 元素For more information, see DataPackage Element

Resources 元素Resources Element

描述此服务使用的资源,可以在不修改已编译代码的情况下声明,并可以在部署服务时更改。Describes the resources used by this service, which can be declared without modifying compiled code and changed when the service is deployed. 通过应用程序清单的 Principals 和 Policies 节控制对这些资源的访问。Access to these resources is controlled through the Principals and Policies sections of the application manifest. 有关详细信息,请参阅 Resources 元素For more information, see Resources Element

Endpoints 元素Endpoints Element

定义服务的终结点。Defines endpoints for the service. 有关详细信息,请参阅 Endpoints 元素For more information, see Endpoints Element

Endpoint 元素Endpoint Element

服务清单中声明的要重写的终结点。The endpoint, declared in the service manifest, to override. 有关详细信息,请参阅 Endpoint 元素For more information, see Endpoint Element