Azure 云服务定义 WorkerRole 架构Azure Cloud Services Definition WorkerRole Schema
Azure 辅助角色对普通开发非常有用,可为 web 角色执行后台处理。The Azure worker role is a role that is useful for generalized development, and may perform background processing for a web role.
服务定义文件的默认扩展名为 .csdef。The default extension for the service definition file is .csdef.
辅助角色的基本服务定义架构。Basic service definition schema for a worker role.
对于包含辅助角色的服务定义文件,其基本格式如下所示。The basic format of the service definition file containing a worker role is as follows.
<ServiceDefinition …>
<WorkerRole name="<worker-role-name>" vmsize="<worker-role-size>" enableNativeCodeExecution="[true|false]">
<Certificates>
<Certificate name="<certificate-name>" storeLocation="[CurrentUser|LocalMachine]" storeName="[My|Root|CA|Trust|Disallow|TrustedPeople|TrustedPublisher|AuthRoot|AddressBook|<custom-store>" />
</Certificates>
<ConfigurationSettings>
<Setting name="<setting-name>" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="<input-endpoint-name>" protocol="[http|https|tcp|udp]" localPort="<local-port-number>" port="<port-number>" certificate="<certificate-name>" loadBalancerProbe="<load-balancer-probe-name>" />
<InternalEndpoint name="<internal-endpoint-name" protocol="[http|tcp|udp|any]" port="<port-number>">
<FixedPort port="<port-number>"/>
<FixedPortRange min="<minimum-port-number>" max="<maximum-port-number>"/>
</InternalEndpoint>
<InstanceInputEndpoint name="<instance-input-endpoint-name>" localPort="<port-number>" protocol="[udp|tcp]">
<AllocatePublicPortFrom>
<FixedPortRange min="<minimum-port-number>" max="<maximum-port-number>"/>
</AllocatePublicPortFrom>
</InstanceInputEndpoint>
</Endpoints>
<Imports>
<Import moduleName="[RemoteAccess|RemoteForwarder|Diagnostics]"/>
</Imports>
<LocalResources>
<LocalStorage name="<local-store-name>" cleanOnRoleRecycle="[true|false]" sizeInMB="<size-in-megabytes>" />
</LocalResources>
<LocalStorage name="<local-store-name>" cleanOnRoleRecycle="[true|false]" sizeInMB="<size-in-megabytes>" />
<Runtime executionContext="[limited|elevated]">
<Environment>
<Variable name="<variable-name>" value="<variable-value>">
<RoleInstanceValue xpath="<xpath-to-role-environment-settings>"/>
</Variable>
</Environment>
<EntryPoint>
<NetFxEntryPoint assemblyName="<name-of-assembly-containing-entrypoint>" targetFrameworkVersion="<.net-framework-version>"/>
<ProgramEntryPoint commandLine="<application>" setReadyOnProcessStart="[true|false]"/>
</EntryPoint>
</Runtime>
<Startup priority="<for-internal-use-only>">
<Task commandLine="" executionContext="[limited|elevated]" taskType="[simple|foreground|background]">
<Environment>
<Variable name="<variable-name>" value="<variable-value>">
<RoleInstanceValue xpath="<xpath-to-role-environment-settings>"/>
</Variable>
</Environment>
</Task>
</Startup>
<Contents>
<Content destination="<destination-folder-name>" >
<SourceDirectory path="<local-source-directory>" />
</Content>
</Contents>
</WorkerRole>
</ServiceDefinition>
架构元素Schema Elements
服务定义文件包括以下元素,本主题的后续部分将进行详细说明:The service definition file includes these elements, described in detail in subsequent sections in this topic:
ConfigurationSettingsConfigurationSettings
InternalEndpointInternalEndpoint
InstanceInputEndpointInstanceInputEndpoint
AllocatePublicPortFromAllocatePublicPortFrom
NetFxEntryPointNetFxEntryPoint
ProgramEntryPointProgramEntryPoint
RoleInstanceValueRoleInstanceValue
ServiceDefinition.csdefStartup
SourceDirectorySourceDirectory
WorkerRoleWorkerRole
WorkerRole
元素描述一个对普通开发非常有用并且可为 web 角色执行后台处理的角色。The WorkerRole
element describes a role that is useful for generalized development, and may perform background processing for a web role. 一个服务可能包含零个或多个辅助角色。A service may contain zero or more worker roles.
下表介绍了 WorkerRole
元素的属性。The following table describes the attributes of the WorkerRole
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 辅助角色的名称。The name for the worker role. 角色名称必须唯一。The role's name must be unique. |
enableNativeCodeExecutionenableNativeCodeExecution | 布尔值boolean | 可选。Optional. 默认值是 true 默认启用本机代码执行和完全信任。The default value is true ; native code execution and full trust are enabled by default. 将此属性设置为 false ,可禁用辅助角色的本机代码执行,并改为使用 Azure 部分信任。Set this attribute to false to disable native code execution for the worker role, and use Azure partial trust instead. |
vmsizevmsize | 字符串string | 可选。Optional. 设置此值可更改分配给此角色的虚拟机的大小。Set this value to change the size of the virtual machine that is allotted to this role. 默认值为 Small 。The default value is Small . 有关可能的虚拟机大小及其属性的列表,请参阅云服务的虚拟机大小。For a list of possible virtual machine sizes and their attributes, see Virtual Machine sizes for Cloud Services. |
ConfigurationSettingsConfigurationSettings
ConfigurationSettings
元素描述辅助角色的配置设置集。The ConfigurationSettings
element describes the collection of configuration settings for a worker role. 此元素是 Setting
元素的父级。This element is the parent of the Setting
element.
SettingSetting
Setting
元素描述用于为角色实例指定配置设置的名称和值对。The Setting
element describes a name and value pair that specifies a configuration setting for an instance of a role.
下表介绍了 Setting
元素的属性。The following table describes the attributes of the Setting
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 配置设置的唯一名称。A unique name for the configuration setting. |
角色的配置设置是在服务定义文件中声明并在服务配置文件中设置的名称-值对。The configuration settings for a role are name and value pairs that are declared in the service definition file and set in the service configuration file.
LocalResourcesLocalResources
LocalResources
元素描述辅助角色的本地存储资源集。The LocalResources
element describes the collection of local storage resources for a worker role. 此元素是 LocalStorage
元素的父级。This element is the parent of the LocalStorage
element.
LocalStorageLocalStorage
LocalStorage
元素标识用于在运行时为服务提供文件系统空间的本地存储资源。The LocalStorage
element identifies a local storage resource that provides file system space for the service at runtime. 一个角色可以定义零个或多个本地存储资源。A role may define zero or more local storage resources.
备注
LocalStorage
元素可显示为 WorkerRole
元素的子级,提供与早期版本的 Azure SDK 的兼容性。The LocalStorage
element can appear as a child of the WorkerRole
element to support compatibility with earlier versions of the Azure SDK.
下表介绍了 LocalStorage
元素的属性。The following table describes the attributes of the LocalStorage
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 本地存储的唯一名称。A unique name for the local store. |
cleanOnRoleRecyclecleanOnRoleRecycle | 布尔值boolean | 可选。Optional. 指示重启角色时是否应清理本地存储。Indicates whether the local store should be cleaned when the role is restarted. 默认值为 true 。Default value is true . |
sizeInMbsizeInMb | intint | 可选。Optional. 需要为本地存储分配的存储空间量,以 MB 为单位。The desired amount of storage space to allocate for the local store, in MB. 如果未指定,则分配的默认存储空间为 100 MB。If not specified, the default storage space allocated is 100 MB. 可分配的最小存储空间量为 1 MB。The minimum amount of storage space that may be allocated is 1 MB. 最大的本地资源大小取决于虚拟机大小。The maximum size of the local resources is dependent on the virtual machine size. 有关详细信息,请参阅云服务的虚拟机大小。For more information, see Virtual Machine sizes for Cloud Services. |
分配给本地存储资源的目录的名称对应于为名称属性提供的值。The name of the directory allocated to the local storage resource corresponds to the value provided for the name attribute.
EndpointsEndpoints
Endpoints
元素描述角色的输入(外部)、内部和实例输入终结点的集合。The Endpoints
element describes the collection of input (external), internal, and instance input endpoints for a role. 此元素是 InputEndpoint
、InternalEndpoint
和 InstanceInputEndpoint
元素的父级。This element is the parent of the InputEndpoint
, InternalEndpoint
, and InstanceInputEndpoint
elements.
输入和内部终结点是单独分配的。Input and Internal endpoints are allocated separately. 一个服务可共有 25 个输入、内部和实例输入终结点,这些终结点可在一个服务中允许存在的 25 个角色间分配。A service can have a total of 25 input, internal, and instance input endpoints which can be allocated across the 25 roles allowed in a service. 例如,如果有 5 个角色,则可以向每个角色分配 5 个输入终结点,或者向一个角色分配 25 个输入终结点,或者可以向 25 个角色中的每个角色分配 1 个输入终结点。For example, if have 5 roles you can allocate 5 input endpoints per role or you can allocate 25 input endpoints to a single role or you can allocate 1 input endpoint each to 25 roles.
备注
部署的每个角色需要一个实例。Each role deployed requires one instance per role. 订阅的默认预配限制为 20 个内核,因此最多可有 20 个角色实例。The default provisioning for a subscription is limited to 20 cores and thus is limited to 20 instances of a role. 如果应用程序需要的实例数比默认预配提供的数目更多,请参阅计费、订阅管理和配额支持,了解有关提高配额的详细信息。If your application requires more instances than is provided by the default provisioning see Billing, Subscription Management and Quota Support for more information on increasing your quota.
InputEndpointInputEndpoint
InputEndpoint
元素描述辅助角色的外部终结点。The InputEndpoint
element describes an external endpoint to a worker role.
可以定义由 HTTP、HTTPS、UDP 和 TCP 终结点组成的多个终结点。You can define multiple endpoints that are a combination of HTTP, HTTPS, UDP, and TCP endpoints. 可以指定为输入终结点选择的任意端口号,但为服务中每个角色指定的端口号必须唯一。You can specify any port number you choose for an input endpoint, but the port numbers specified for each role in the service must be unique. 例如,如果指定一个角色将端口 80 用于 HTTP,将端口 443 用于 HTTPS,则之后可能会指定第二个角色将端口 8080 用于 HTTP,将端口 8043 用于 HTTPS。For example, if you specify that a role uses port 80 for HTTP and port 443 for HTTPS, you might then specify that a second role uses port 8080 for HTTP and port 8043 for HTTPS.
下表介绍了 InputEndpoint
元素的属性。The following table describes the attributes of the InputEndpoint
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 外部终结点的唯一名称。A unique name for the external endpoint. |
协议protocol | 字符串string | 必需。Required. 外部终结点的传输协议。The transport protocol for the external endpoint. 对于辅助角色,可能的值为 HTTP 、HTTPS 、UDP 或 TCP 。For a worker role, possible values are HTTP , HTTPS , UDP , or TCP . |
端口port | intint | 必需。Required. 外部终结点的端口。The port for the external endpoint. 可以指定所选的任意端口号,但为服务中每个角色指定的端口号必须唯一。You can specify any port number you choose, but the port numbers specified for each role in the service must be unique. 可能的值介于 1 和 65535(包含在内)之间(Azure SDK 1.7 或更高版本)。Possible values range between 1 and 65535, inclusive (Azure SDK version 1.7 or higher). |
证书certificate | 字符串string | HTTPS 终结点需要。Required for an HTTPS endpoint. 由 Certificate 元素定义的证书的名称。The name of a certificate defined by a Certificate element. |
localPortlocalPort | intint | 可选。Optional. 指定用于终结点上内部连接的端口。Specifies a port used for internal connections on the endpoint. localPort 属性将终结点上的外部端口映射到角色上的内部端口。The localPort attribute maps the external port on the endpoint to an internal port on a role. 这在以下情况下非常有用:角色必须与端口上的内部组件而非为外部公开的组件进行通信。This is useful in scenarios where a role must communicate to an internal component on a port that different from the one that is exposed externally.如果未指定,则 localPort 的值与 port 属性相同。If not specified, the value of localPort is the same as the port attribute. 将 localPort 的值设置为“*”会自动分配可使用运行时 API 发现的未分配端口。Set the value of localPort to “*” to automatically assign an unallocated port that is discoverable using the runtime API.可能的值介于 1 和 65535(包含在内)之间(Azure SDK 1.7 或更高版本)。Possible values range between 1 and 65535, inclusive (Azure SDK version 1.7 or higher). 仅当使用 Azure SDK 1.3 或更高版本时,才提供 localPort 属性。The localPort attribute is only available using the Azure SDK version 1.3 or higher. |
ignoreRoleInstanceStatusignoreRoleInstanceStatus | 布尔值boolean | 可选。Optional. 当此属性的值设置为 true 时,会忽略服务的状态,并且负载均衡器不会删除该终结点。When the value of this attribute is set to true , the status of a service is ignored and the endpoint will not be removed by the load balancer. 此值设置为 true 对调试服务的繁忙实例非常有用。Setting this value to true useful for debugging busy instances of a service. 默认值为 false 。The default value is false . 注意: 即使角色不处于就绪状态,终结点仍可接收流量。Note: An endpoint can still receive traffic even when the role is not in a Ready state. |
loadBalancerProbeloadBalancerProbe | 字符串string | 可选。Optional. 与输入终结点关联的负载均衡器探测的名称。The name of the load balancer probe associated with the input endpoint. 有关详细信息,请参阅 LoadBalancerProbe 架构。For more information, see LoadBalancerProbe Schema. |
InternalEndpointInternalEndpoint
InternalEndpoint
元素描述辅助角色的内部终结点。The InternalEndpoint
element describes an internal endpoint to a worker role. 只向服务中运行的其他角色实例提供内部终结点,而不向服务外部的客户端提供。An internal endpoint is available only to other role instances running within the service; it is not available to clients outside the service. 辅助角色最多具有五个 HTTP、UDP 或 TCP 内部终结点。A worker role may have up to five HTTP, UDP, or TCP internal endpoints.
下表介绍了 InternalEndpoint
元素的属性。The following table describes the attributes of the InternalEndpoint
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 内部终结点的唯一名称。A unique name for the internal endpoint. |
协议protocol | 字符串string | 必需。Required. 内部终结点的传输协议。The transport protocol for the internal endpoint. 可能的值为 HTTP 、TCP 、UDP 或 ANY 。Possible values are HTTP , TCP , UDP , or ANY .ANY 的值指定允许任何协议、任何端口。A value of ANY specifies that any protocol, any port is allowed. |
端口port | intint | 可选。Optional. 用于终结点上内部负载均衡连接的端口。The port used for internal load balanced connections on the endpoint. 负载均衡的终结点使用两个端口。A Load balanced endpoint uses two ports. 用于公共 IP 地址的端口,以及用于专用 IP 地址的端口。The port used for the public IP address, and the port used on the private IP address. 通常这些端口的设置相同,但可以选择使用不同的端口。Typically these are these are set to the same, but you can choose to use different ports. 可能的值介于 1 和 65535(包含在内)之间(Azure SDK 1.7 或更高版本)。Possible values range between 1 and 65535, inclusive (Azure SDK version 1.7 or higher). 仅当使用 Azure SDK 1.3 或更高版本时,才提供 Port 属性。The Port attribute is only available using the Azure SDK version 1.3 or higher. |
InstanceInputEndpointInstanceInputEndpoint
InstanceInputEndpoint
元素描述辅助角色的实例输入终结点。The InstanceInputEndpoint
element describes an instance input endpoint to a worker role. 实例输入终结点通过使用负载均衡器中的端口转接,关联到特定的角色实例。An instance input endpoint is associated with a specific role instance by using port forwarding in the load balancer. 每个实例输入终结点映射到一系列可能端口中的特定端口。Each instance input endpoint is mapped to a specific port from a range of possible ports. 此元素是 AllocatePublicPortFrom
元素的父级。This element is the parent of the AllocatePublicPortFrom
element.
仅当使用 Azure SDK 1.7 或更高版本时,才提供 InstanceInputEndpoint
元素。The InstanceInputEndpoint
element is only available using the Azure SDK version 1.7 or higher.
下表介绍了 InstanceInputEndpoint
元素的属性。The following table describes the attributes of the InstanceInputEndpoint
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 终结点的唯一名称。A unique name for the endpoint. |
localPortlocalPort | intint | 必需。Required. 指定需要所有角色实例均对其侦听才能接收负载均衡器转发的传入流量的内部端口。Specifies the internal port that all role instances will listen to in order to receive incoming traffic forwarded from the load balancer. 可能的值介于 1 和 65535(含)之间。Possible values range between 1 and 65535, inclusive. |
协议protocol | 字符串string | 必需。Required. 内部终结点的传输协议。The transport protocol for the internal endpoint. 可能的值为 udp 或 tcp 。Possible values are udp or tcp . 将 tcp 用于基于 http/https 的流量。Use tcp for http/https based traffic. |
AllocatePublicPortFromAllocatePublicPortFrom
AllocatePublicPortFrom
元素描述可供外部客户用来访问每个实例输入终结点的公共端口范围。The AllocatePublicPortFrom
element describes the public port range that can be used by external customers to access each instance input endpoint. 公共 (VIP) 端口号在此范围中分配,并在租户部署和更新过程中分配给每个单独的角色实例终结点。The public (VIP) port number is allocated from this range and assigned to each individual role instance endpoint during tenant deployment and update. 此元素是 FixedPortRange
元素的父级。This element is the parent of the FixedPortRange
element.
仅当使用 Azure SDK 1.7 或更高版本时,才提供 AllocatePublicPortFrom
元素。The AllocatePublicPortFrom
element is only available using the Azure SDK version 1.7 or higher.
FixedPortFixedPort
FixedPort
元素指定内部终结点的端口,用于在该终结点上实现负载均衡的连接。The FixedPort
element specifies the port for the internal endpoint, which enables load balanced connections on the endpoint.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 FixedPort
元素。The FixedPort
element is only available using the Azure SDK version 1.3 or higher.
下表介绍了 FixedPort
元素的属性。The following table describes the attributes of the FixedPort
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
端口port | intint | 必需。Required. 内部终结点的端口。The port for the internal endpoint. 其效果与将 FixedPortRange min 和 max 设置为相同的端口一样。This has the same effect as setting the FixedPortRange min and max to the same port.可能的值介于 1 和 65535(包含在内)之间(Azure SDK 1.7 或更高版本)。Possible values range between 1 and 65535, inclusive (Azure SDK version 1.7 or higher). |
FixedPortRangeFixedPortRange
FixedPortRange
元素指定分配给内部终结点或实例输入终结点的端口的范围,并设置用于在终结点上建立负载均衡连接的端口。The FixedPortRange
element specifies the range of ports that are assigned to the internal endpoint or instance input endpoint, and sets the port used for load balanced connections on the endpoint.
备注
FixedPortRange
元素的工作方式取决于它所在的元素。The FixedPortRange
element works differently depending on the element in which it resides. 当 FixedPortRange
元素位于 InternalEndpoint
元素中时,它会为运行角色的所有虚拟机打开负载均衡器上 min 和 max 属性范围内的所有端口。When the FixedPortRange
element is in the InternalEndpoint
element, it opens all ports on the load balancer within the range of the min and max attributes for all virtual machines on which the role runs. 当 FixedPortRange
元素位于 InstanceInputEndpoint
元素中时,它会在运行角色的每个虚拟机上只打开 min 和 max 属性范围内的一个端口。When the FixedPortRange
element is in the InstanceInputEndpoint
element, it opens only one port within the range of the min and max attributes on each virtual machine running the role.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 FixedPortRange
元素。The FixedPortRange
element is only available using the Azure SDK version 1.3 or higher.
下表介绍了 FixedPortRange
元素的属性。The following table describes the attributes of the FixedPortRange
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
minmin | intint | 必需。Required. 范围内的最小端口。The minimum port in the range. 可能的值介于 1 和 65535(包含在内)之间(Azure SDK 1.7 或更高版本)。Possible values range between 1 and 65535, inclusive (Azure SDK version 1.7 or higher). |
maxmax | 字符串string | 必需。Required. 范围内的最大端口。The maximum port in the range. 可能的值介于 1 和 65535(包含在内)之间(Azure SDK 1.7 或更高版本)。Possible values range between 1 and 65535, inclusive (Azure SDK version 1.7 or higher). |
CertificatesCertificates
Certificates
元素描述辅助角色的证书集。The Certificates
element describes the collection of certificates for a worker role. 此元素是 Certificate
元素的父级。This element is the parent of the Certificate
element. 一个角色可以包含任意数目的关联证书。A role may have any number of associated certificates. 有关使用 certificates 元素的详细信息,请参阅使用证书修改服务定义文件。For more information on using the certificates element, see Modify the Service Definition file with a certificate.
CertificateCertificate
Certificate
元素描述与辅助角色关联的证书。The Certificate
element describes a certificate that is associated with a worker role.
下表介绍了 Certificate
元素的属性。The following table describes the attributes of the Certificate
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 此证书的名称,用于与 HTTPS InputEndpoint 元素关联时进行引用。A name for this certificate, which is used to refer to it when it is associated with an HTTPS InputEndpoint element. |
storeLocationstoreLocation | 字符串string | 必需。Required. 本地计算机上的证书存储位置,可在其中找到此证书。The location of the certificate store where this certificate may be found on the local machine. 可能的值为 CurrentUser 和 LocalMachine 。Possible values are CurrentUser and LocalMachine . |
storeNamestoreName | 字符串string | 必需。Required. 本地计算机上此证书所在的证书存储的名称。The name of the certificate store where this certificate resides on the local machine. 可能的值包括内置存储名称 My 、Root 、CA 、Trust 、Disallowed 、TrustedPeople 、TrustedPublisher 、AuthRoot 、AddressBook ,或任何自定义存储名称。Possible values include the built-in store names My , Root , CA , Trust , Disallowed , TrustedPeople , TrustedPublisher , AuthRoot , AddressBook , or any custom store name. 如果指定了自定义存储名称,则会自动创建存储。If a custom store name is specified, the store is automatically created. |
permissionLevelpermissionLevel | 字符串string | 可选。Optional. 指定授予角色进程的访问权限。Specifies the access permissions given to the role processes. 如果只希望提升的进程访问私钥,则指定 elevated 权限。If you want only elevated processes to be able to access the private key, then specify elevated permission. limitedOrElevated 权限允许所有角色进程访问私钥。limitedOrElevated permission allows all role processes to access the private key. 可能的值为 limitedOrElevated 或 elevated 。Possible values are limitedOrElevated or elevated . 默认值为 limitedOrElevated 。The default value is limitedOrElevated . |
ImportsImports
Imports
元素描述辅助角色的导入模块集,它会向来宾操作系统添加组件。The Imports
element describes a collection of import modules for a worker role that add components to the guest operating system. 此元素是 Import
元素的父级。This element is the parent of the Import
element. 此元素是可选的,一个角色只能有一个运行时块。This element is optional and a role can have only one runtime block.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 Imports
元素。The Imports
element is only available using the Azure SDK version 1.3 or higher.
ImportImport
Import
元素指定要添加到来宾操作系统的模块。The Import
element specifies a module to add to the guest operating system.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 Import
元素。The Import
element is only available using the Azure SDK version 1.3 or higher.
下表介绍了 Import
元素的属性。The following table describes the attributes of the Import
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
moduleNamemoduleName | 字符串string | 必需。Required. 要导入的模块的名称。The name of the module to import. 有效的导入模块为:Valid import modules are: - RemoteAccess- RemoteAccess - RemoteForwarder- RemoteForwarder - Diagnostics- Diagnostics 借助 RemoteAccess 和 RemoteForwarder 模块,可配置远程桌面连接的角色实例。The RemoteAccess and RemoteForwarder modules allow you to configure your role instance for remote desktop connections. 有关详细信息,请参阅启用远程桌面连接。For more information see Enable Remote Desktop Connection. 借助 Diagnostics 模块,可收集角色实例的诊断数据The Diagnostics module allows you to collect diagnostic data for a role instance |
RuntimeRuntime
Runtime
元素描述辅助角色的环境变量设置集,这些设置用于控制 Azure 主机进程的运行时环境。The Runtime
element describes a collection of environment variable settings for a worker role that control the runtime environment of the Azure host process. 此元素是 Environment
元素的父级。This element is the parent of the Environment
element. 此元素是可选的,一个角色只能有一个运行时块。This element is optional and a role can have only one runtime block.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 Runtime
元素。The Runtime
element is only available using the Azure SDK version 1.3 or higher.
下表描述 Runtime
元素的属性:The following table describes the attributes of the Runtime
element:
属性Attribute | 类型Type | 说明Description |
---|---|---|
executionContextexecutionContext | 字符串string | 可选。Optional. 指定在其中启动角色进程的上下文。Specifies the context in which the Role Process is launched. 默认上下文为 limited 。The default context is limited .- limited – 不使用管理员特权启动进程。- limited – The process is launched without Administrator privileges.- elevated – 需要管理员权限才能启动进程。- elevated – The process is launched with Administrator privileges. |
EnvironmentEnvironment
Environment
元素描述辅助角色的环境变量设置集。The Environment
element describes a collection of environment variable settings for a worker role. 此元素是 Variable
元素的父级。This element is the parent of the Variable
element. 一个角色可以包含任意数目的环境变量集。A role may have any number of environment variables set.
VariableVariable
Variable
元素指定要在来宾操作系统中设置的环境变量。The Variable
element specifies an environment variable to set in the guest operating.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 Variable
元素。The Variable
element is only available using the Azure SDK version 1.3 or higher.
下表描述 Variable
元素的属性:The following table describes the attributes of the Variable
element:
属性Attribute | 类型Type | 说明Description |
---|---|---|
namename | 字符串string | 必需。Required. 要设置的环境变量的名称。The name of the environment variable to set. |
valuevalue | 字符串string | 可选。Optional. 要为环境变量设置的值。The value to set for the environment variable. 必须包含 value 属性或 RoleInstanceValue 元素。You must include either a value attribute or a RoleInstanceValue element. |
RoleInstanceValueRoleInstanceValue
RoleInstanceValue
元素指定要从其中检索变量值的 xPath。The RoleInstanceValue
element specifies the xPath from which to retrieve the value of the variable.
下表介绍了 RoleInstanceValue
元素的属性。The following table describes the attributes of the RoleInstanceValue
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
xpathxpath | 字符串string | 可选。Optional. 实例的部署设置的位置路径。Location path of deployment settings for the instance. 有关详细信息,请参阅带有 XPath 的配置变量。For more information, see Configuration variables with XPath. 必须包含 value 属性或 RoleInstanceValue 元素。You must include either a value attribute or a RoleInstanceValue element. |
EntryPointEntryPoint
EntryPoint
元素指定角色的入口点。The EntryPoint
element specifies the entry point for a role. 此元素是 NetFxEntryPoint
元素的父级。This element is the parent of the NetFxEntryPoint
elements. 借助这些元素,可以指定默认 WaWorkerHost.exe 以外的应用程序充当角色入口点。These elements allow you to specify an application other than the default WaWorkerHost.exe to act as the role entry point.
仅当使用 Azure SDK 1.5 或更高版本时,才提供 EntryPoint
元素。The EntryPoint
element is only available using the Azure SDK version 1.5 or higher.
NetFxEntryPointNetFxEntryPoint
NetFxEntryPoint
元素指定要为角色运行的程序。The NetFxEntryPoint
element specifies the program to run for a role.
备注
仅当使用 Azure SDK 1.5 或更高版本时,才提供 NetFxEntryPoint
元素。The NetFxEntryPoint
element is only available using the Azure SDK version 1.5 or higher.
下表介绍了 NetFxEntryPoint
元素的属性。The following table describes the attributes of the NetFxEntryPoint
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
assemblyNameassemblyName | 字符串string | 必需。Required. 包含入口点的程序集的路径和文件名称。The path and file name of the assembly containing the entry point. 该路径相对于文件夹 \%ROLEROOT%\Approot(请勿在 commandLine 中指定 \%ROLEROOT%\Approot,它是假定的)。The path is relative to the folder \%ROLEROOT%\Approot (do not specify \%ROLEROOT%\Approot in commandLine , it is assumed). %ROLEROOT% 是由 Azure 维护的环境变量,表示角色的根文件夹位置。%ROLEROOT% is an environment variable maintained by Azure and it represents the root folder location for your role. \%ROLEROOT%\Approot 文件夹表示角色的应用程序文件夹。The \%ROLEROOT%\Approot folder represents the application folder for your role. |
targetFrameworkVersiontargetFrameworkVersion | 字符串string | 必需。Required. 在其上生成程序集的 .NET Framework 的版本。The version of the .NET framework on which the assembly was built. 例如,targetFrameworkVersion="v4.0" 。For example, targetFrameworkVersion="v4.0" . |
ProgramEntryPointProgramEntryPoint
ProgramEntryPoint
元素指定要为角色运行的程序。The ProgramEntryPoint
element specifies the program to run for a role. ProgramEntryPoint
元素允许你指定不基于 .NET 程序集的程序入口点。The ProgramEntryPoint
element allows you to specify a program entry point that is not based on a .NET assembly.
备注
仅当使用 Azure SDK 1.5 或更高版本时,才提供 ProgramEntryPoint
元素。The ProgramEntryPoint
element is only available using the Azure SDK version 1.5 or higher.
下表介绍了 ProgramEntryPoint
元素的属性。The following table describes the attributes of the ProgramEntryPoint
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
commandLinecommandLine | 字符串string | 必需。Required. 要执行的程序的路径、文件名和任何命令行参数。The path, file name, and any command line arguments of the program to execute. 该路径相对于文件夹 %ROLEROOT%\Approot(请勿在 commandLine 中指定 %ROLEROOT%\Approot,它是假定的)。The path is relative to the folder %ROLEROOT%\Approot (do not specify %ROLEROOT%\Approot in commandLine, it is assumed). %ROLEROOT% 是由 Azure 维护的环境变量,它表示角色的根文件夹位置。%ROLEROOT% is an environment variable maintained by Azure and it represents the root folder location for your role. %ROLEROOT%\Approot 文件夹表示角色的应用程序文件夹。The %ROLEROOT%\Approot folder represents the application folder for your role. 程序结束后会回收该角色,所以通常会将程序设置为继续运行,而不是启动后运行有限的任务。If the program ends, the role is recycled, so generally set the program to continue to run, instead of being a program that just starts up and runs a finite task. |
setReadyOnProcessStartsetReadyOnProcessStart | 布尔值boolean | 必需。Required. 指定角色实例是否等待命令行程序表明它已启动。Specifies whether the role instance waits for the command line program to signal it is started. 此时,此值必须设置为 true 。This value must be set to true at this time. 保留将该值设置为 false 这一操作,供将来使用。Setting the value to false is reserved for future use. |
StartupStartup
Startup
元素描述角色启动时运行的任务的集合。The Startup
element describes a collection of tasks that run when the role is started. 此元素可以是 Variable
元素的父级。This element can be the parent of the Variable
element. 有关使用角色启动任务的详细信息,请参阅如何配置启动任务。For more information about using the role startup tasks, see How to configure startup tasks. 此元素是可选的,一个角色只能有一个启动块。This element is optional and a role can have only one startup block.
下表描述 Startup
元素的属性。The following table describes the attribute of the Startup
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
prioritypriority | intint | 仅供内部使用。For internal use only. |
TaskTask
Task
元素指定在角色启动时发生的启动任务。The Task
element specifies startup task that takes place when the role starts. 启动任务可用于执行准备角色以运行的任务,如安装软件组件或运行其他应用程序。Startup tasks can be used to perform tasks that prepare the role to run such install software components or run other applications. 这些任务会按照它们在 Startup
元素块中出现的顺序执行。Tasks execute in the order in which they appear within the Startup
element block.
仅当使用 Azure SDK 1.3 或更高版本时,才提供 Task
元素。The Task
element is only available using the Azure SDK version 1.3 or higher.
下表介绍了 Task
元素的属性。The following table describes the attributes of the Task
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
commandLinecommandLine | 字符串string | 必需。Required. 包含要运行的命令的脚本(如 CMD 文件)。A script, such as a CMD file, containing the commands to run. 启动命令和批处理文件必须以 ANSI 格式保存。Startup command and batch files must be saved in ANSI format. 在文件开头设置字节顺序标记的文件格式无法得到正确处理。File formats that set a byte-order marker at the start of the file will not process properly. |
executionContextexecutionContext | 字符串string | 指定在其中运行脚本的上下文。Specifies the context in which the script is run. - limited [默认] – 使用与托管进程的角色相同的特权运行。- limited [Default] – Run with the same privileges as the role hosting the process.- elevated – 使用管理员特权运行。- elevated – Run with administrator privileges. |
taskTypetaskType | 字符串string | 指定命令的执行行为。Specifies the execution behavior of the command. - simple [默认] – 系统等待任务退出,然后再启动其他所有任务。- simple [Default] – System waits for the task to exit before any other tasks are launched.- background – 系统不会等待任务退出。- background – System does not wait for the task to exit.- foreground – 与后台相似,但所有前台任务全部退出之前,不会重启角色。- foreground – Similar to background, except role is not restarted until all foreground tasks exit. |
ContentsContents
Contents
元素描述辅助角色的内容集。The Contents
element describes the collection of content for a worker role. 此元素是 Content
元素的父级。This element is the parent of the Content
element.
仅当使用 Azure SDK 1.5 或更高版本时,才提供 Contents
元素。The Contents
element is only available using the Azure SDK version 1.5 or higher.
ContentContent
Content
元素定义要复制到 Azure 虚拟机的内容的源位置,以及要复制到的目标路径。The Content
element defines the source location of content to be copied to the Azure virtual machine and the destination path to which it is copied.
仅当使用 Azure SDK 1.5 或更高版本时,才提供 Content
元素。The Content
element is only available using the Azure SDK version 1.5 or higher.
下表介绍了 Content
元素的属性。The following table describes the attributes of the Content
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
目标destination | 字符串string | 必需。Required. 内容放置在 Azure 虚拟机上的位置。Location on the Azure virtual machine to which the content is placed. 此位置相对于文件夹 %ROLEROOT%\Approot。This location is relative to the folder %ROLEROOT%\Approot. |
此元素是 SourceDirectory
元素的父元素。This element is the parent element of the SourceDirectory
element.
SourceDirectorySourceDirectory
SourceDirectory
元素定义要从中复制内容的本地目录。The SourceDirectory
element defines the local directory from which content is copied. 使用此元素指定要复制到 Azure 虚拟机的本地内容。Use this element to specify the local contents to copy to the Azure virtual machine.
仅当使用 Azure SDK 1.5 或更高版本时,才提供 SourceDirectory
元素。The SourceDirectory
element is only available using the Azure SDK version 1.5 or higher.
下表介绍了 SourceDirectory
元素的属性。The following table describes the attributes of the SourceDirectory
element.
属性Attribute | 类型Type | 说明Description |
---|---|---|
pathpath | 字符串string | 必需。Required. 内容将复制到 Azure 虚拟机的本地目录的相对或绝对路径。Relative or absolute path of a local directory whose contents will be copied to the Azure virtual machine. 支持扩展目录路径中的环境变量。Expansion of environment variables in the directory path is supported. |