Azure 经典 VM 体系结构的工作流Workflow of Azure classic VM Architecture

本文概述当你部署或更新虚拟机等 Azure 资源时发生的工作流过程。This article provides an overview of the workflow processes that occur when you deploy or update an Azure resource such as a virtual machine.

备注

Azure 具有用于创建和处理资源的两个不同的部署模型:资源管理器部署模型和经典部署模型。Azure has two different deployment models for creating and working with resources: Resource Manager and classic. 本文介绍使用经典部署模型的情况。This article covers using the classic deployment model.

下图显示了 Azure 资源的体系结构。The following diagram presents the architecture of Azure resources.

<alt 关于 Azure 工作流的图像>

工作流基础知识Workflow basics

A . RDFE/FFE 是从用户到结构的通信路径。RDFE / FFE is the communication path from the user to the fabric. RDFE(RedDog 前端)是公开的 API,它是管理门户以及 Visual Studio、Azure MMC 等服务管理 API 的前端。RDFE (RedDog Front End) is the publicly exposed API that is the front end to the Management Portal and the Service Management API such as Visual Studio, Azure MMC, and so on. 来自用户的所有请求都会通过 RDFE。All requests from the user go through RDFE. FFE(结构前端)是将请求从 RDFE 转换为结构命令的层。FFE (Fabric Front End) is the layer that translates requests from RDFE into fabric commands. 来自 RDFE 的所有请求都会通过 FFE 抵达结构控制器。All requests from RDFE go through the FFE to reach the fabric controllers.

B .B . 结构控制器负责维护和监视数据中心内的所有资源。The fabric controller is responsible for maintaining and monitoring all the resources in the data center. 它与结构 OS 上的、发送来宾 OS 版本、服务包、服务配置和服务状态等信息的结构主机代理通信。It communicates with fabric host agents on the fabric OS sending information such as the Guest OS version, service package, service configuration, and service state.

C .C . 主机代理驻留在主机 OS 上,负责设置来宾 OS,并与来宾代理 (WindowsAzureGuestAgent) 通信,以便将角色更新到预期的目标状态,并使用来宾代理执行检测信号检查。The Host Agent lives on the Host OS and is responsible for setting up Guest OS and communicating with Guest Agent (WindowsAzureGuestAgent) in order to update the role toward an intended goal state and do heartbeat checks with the Guest agent. 如果主机代理有 10 分钟未收到检测信号响应,则主机代理会重启来宾 OS。If Host Agent does not receive heartbeat response for 10 minutes, Host Agent restarts the Guest OS.

C2 .C2 . WaAppAgent 负责安装、配置和更新 WindowsAzureGuestAgent.exe。WaAppAgent is responsible for installing, configuring, and updating WindowsAzureGuestAgent.exe.

D .D . WindowsAzureGuestAgent 负责:WindowsAzureGuestAgent is responsible for the following:

  1. 配置来宾 OS,包括防火墙、ACL、LocalStorage 资源、服务包和配置,以及证书。Configuring the Guest OS including firewall, ACLs, LocalStorage resources, service package and configuration, and certificates.
  2. 为角色将在其下运行的用户帐户设置 SID。Setting up the SID for the user account that the role will run under.
  3. 向结构传达角色状态。Communicating the role status to the fabric.
  4. 启动并监视 WaHostBootstrapper,以确保角色处于目标状态。Starting WaHostBootstrapper and monitoring it to make sure that the role is in goal state.

E .E . WaHostBootstrapper 负责:WaHostBootstrapper is responsible for:

  1. 读取角色配置,并启动所有相应的任务与进程来配置和运行角色。Reading the role configuration, and starting all the appropriate tasks and processes to configure and run the role.
  2. 监视其所有子进程。Monitoring all its child processes.
  3. 针对角色主机进程引发 StatusCheck 事件。Raising the StatusCheck event on the role host process.

F .F . 如果角色配置为完整的 IIS Web 角色,IISConfigurator 将会运行(它不会针对 SDK 1.2 HWC 角色运行)。IISConfigurator runs if the role is configured as a Full IIS web role (it will not run for SDK 1.2 HWC roles). 它负责:It is responsible for:

  1. 启动标准的 IIS 服务Starting the standard IIS services
  2. 在 Web 配置中配置重写模块Configuring the rewrite module in the web configuration
  3. 为服务模型中配置的角色设置 AppPoolSetting up the AppPool for the configured role in the service model
  4. 将 IIS 日志记录设置为指向 DiagnosticStore LocalStorage 文件夹Setting up IIS logging to point to the DiagnosticStore LocalStorage folder
  5. 配置权限和 ACLConfiguring permissions and ACLs
  6. 网站驻留在 %roleroot%:\sitesroot\0 中,AppPool 指向此位置以运行 IIS。The website resides in %roleroot%:\sitesroot\0, and the AppPool points to this location to run IIS.

G .G . 启动任务由角色模型定义,由 WaHostBootstrapper 启动。Startup tasks are defined by the role model and started by WaHostBootstrapper. 启动任务可配置为以异步方式在后台运行,主机启动程序将启动启动任务,然后继续启动其他启动任务。Startup tasks can be configured to run in the background asynchronously, and the host bootstrapper will start the startup task and then continue on to other startup tasks. 启动任务还可以配置为以简单(默认)模式运行,在此模式下,主机启动程序将等待启动任务完成运行,然后返回成功 (0) 退出代码,接着继续启动下一个启动任务。Startup tasks can also be configured to run in Simple (default) mode in which the host bootstrapper will wait for the startup task to finish running and return a success (0) exit code before continuing to the next startup task.

H .H . 这些任务是 SDK 的一部分,在角色的服务定义 (.csdef) 中定义为插件。These tasks are part of the SDK and are defined as plugins in the role’s service definition (.csdef). 展开到启动任务, DiagnosticsAgentRemoteAccessAgent 的独特之处在于它们各自定义两个启动任务:一个常规启动任务,一个带有 /blockStartup 参数的启动任务。When expanded into startup tasks, the DiagnosticsAgent and RemoteAccessAgent are unique in that they each define two startup tasks, one regular and one that has a /blockStartup parameter. 正常的启动任务定义为后台启动任务,当角色本身正在运行时,该启动任务可在后台运行。The normal startup task is defined as a Background startup task so that it can run in the background while the role itself is running. /blockStartup 启动任务定义为简单启动任务,WaHostBootstrapper 会先等待它退出,然后才继续。The /blockStartup startup task is defined as a Simple startup task so that WaHostBootstrapper waits for it to exit before continuing. /blockStartup 任务等待常规任务完成初始化,然后退出,并允许主机启动程序继续。The /blockStartup task waits for the regular task to finish initializing, and then it exits and allow the host bootstrapper to continue. 这样,便可以在角色进程启动(通过 /blockStartup 任务来实现)之前配置诊断和 RDP 访问。This is done so that diagnostics and RDP access can be configured before the role processes start (this is done through the /blockStartup task). 同时,允许在主机启动程序完成启动任务(通过普通任务来实现)之后继续运行诊断和 RDP 访问。This also allows diagnostics and RDP access to continue running after the host bootstrapper has finished the startup tasks (this is done through the Normal task).

I .I . WaWorkerHost 是正常辅助角色的标准主机进程。WaWorkerHost is the standard host process for normal worker roles. 此主机进程托管角色的所有 DLL 以及入口点代码,例如 OnStart 和 Run。This host process hosts all the role’s DLLs and entry point code, such as OnStart and Run.

J .J . WaIISHost 是使用完整 IIS 的 Web 角色的角色入口点代码的主机进程。WaIISHost is the host process for role entry point code for web roles that use Full IIS. 此进程加载找到的第一个 DLL,该 DLL 使用 RoleEntryPoint 类并从此类执行代码(OnStart、Run、OnStop)。This process loads the first DLL that is found that uses the RoleEntryPoint class and executes the code from this class (OnStart, Run, OnStop). 在 RoleEntryPoint 类中创建的任何 RoleEnvironment 事件(例如 StatusCheck 和 Changed)将在此进程中引发。Any RoleEnvironment events (such as StatusCheck and Changed) that are created in the RoleEntryPoint class are raised in this process.

K .K . W3WP 是标准的 IIS 工作进程,如果角色配置为使用完整 IIS,将使用该进程。W3WP is the standard IIS worker process that is used if the role is configured to use Full IIS. 它运行从 IISConfigurator 配置的 AppPool。This runs the AppPool that is configured from IISConfigurator. 此处创建的任何 RoleEnvironment 事件(例如 StatusCheck 和 Changed)将在此进程中引发。Any RoleEnvironment events (such as StatusCheck and Changed) that are created here are raised in this process. 请注意,如果你订阅了这两个进程中的事件,则 RoleEnvironment 事件将在这两个位置(WaIISHost 和 w3wp.exe)激发。Note that RoleEnvironment events will fire in both locations (WaIISHost and w3wp.exe) if you subscribe to events in both processes.

工作流过程Workflow processes

  1. 用户发出请求(例如上传“.cspkg”和“.cscfg”文件),告知要停止某个资源或做出配置更改,等等。A user makes a request, such as uploading ".cspkg" and ".cscfg" files, telling a resource to stop or making a configuration change, and so on. 可以通过 Azure 门户或者某个使用服务管理 API 的工具(例如 Visual Studio 发布功能)来执行此操作。This can be done through the Azure portal or a tool that uses the Service Management API, such as the Visual Studio Publish feature. 此请求将转到 RDFE,以执行所有订阅相关的工作,然后将请求传达给 FFE。This request goes to RDFE to do all the subscription-related work and then communicate the request to FFE. 剩余的工作流步骤是部署并启动新包。The rest of these workflow steps are to deploy a new package and start it.
  2. FFE 查找正确的计算机池(根据客户的输入,例如地缘组或地理位置;以及结构提供的输入,例如计算机可用性),并与该计算机池中的主结构控制器通信。FFE finds the correct machine pool (based on customer input such, as affinity group or geographical location plus input from the fabric, such as machine availability) and communicates with the master fabric controller in that machine pool.
  3. 结构控制器查找具有可用 CPU 核心的主机(或运转新主机)。The fabric controller finds a host that has available CPU cores (or spins up a new host). 服务包和配置将复制到主机,结构控制器与主机 OS 上的主机代理通信,以部署包(配置 DIP、端口、来宾 OS,等等)。The service package and configuration is copied to the host, and the fabric controller communicates with the host agent on the host OS to deploy the package (configure DIPs, ports, guest OS, and so on).
  4. 主机代理启动来宾 OS 并与来宾代理 (WindowsAzureGuestAgent) 通信。The host agent starts the Guest OS and communicates with the guest agent (WindowsAzureGuestAgent). 主机将检测信号发送到来宾,以确保角色实现其目标状态。The host sends heartbeats to the guest to make sure that the role is working towards its goal state.
  5. WindowsAzureGuestAgent 设置来宾 OS(防火墙、ACL、LocalStorage 等),将新的 XML 配置文件复制到 c:\Config,然后启动 WaHostBootstrapper 进程。WindowsAzureGuestAgent sets up the guest OS (firewall, ACLs, LocalStorage, and so on), copies a new XML configuration file to c:\Config, and then starts the WaHostBootstrapper process.
  6. 对于完整 IIS Web 角色,WaHostBootstrapper 将启动 IISConfigurator,并告诉它要从 IIS 中删除 Web 角色的所有现有 AppPool。For Full IIS web roles, WaHostBootstrapper starts IISConfigurator and tells it to delete any existing AppPools for the web role from IIS.
  7. WaHostBootstrapper 从 E:\RoleModel.xml 读取 启动 任务,并开始执行启动任务。WaHostBootstrapper reads the Startup tasks from E:\RoleModel.xml and begins executing startup tasks. WaHostBootstrapper 等到所有简单启动任务已完成并返回了“成功”消息。WaHostBootstrapper waits until all Simple startup tasks have finished and returned a “success” message.
  8. 对于完整 IIS Web 角色,WaHostBootstrapper 将告知 IISConfigurator 配置 IIS AppPool 并将站点指向 E:\Sitesroot\<index>,其中,<index> 是为服务定义的 <Sites> 元素数目的从 0 开始的索引。For Full IIS web roles, WaHostBootstrapper tells IISConfigurator to configure the IIS AppPool and points the site to E:\Sitesroot\<index>, where <index> is a 0 based index into the number of <Sites> elements defined for the service.
  9. WaHostBootstrapper 将根据角色类型启动主机进程:WaHostBootstrapper will start the host process depending on the role type:
    1. 辅助角色 :WaWorkerHost.exe 已启动。Worker Role : WaWorkerHost.exe is started. WaHostBootstrapper 执行 OnStart() 方法。WaHostBootstrapper executes the OnStart() method. 当它返回后,WaHostBootstrapper 开始执行 Run() 方法,同时将角色标记为 Ready,并将其放入负载均衡器轮换阵容(如果定义了 InputEndpoints)。After it returns, WaHostBootstrapper starts to execute the Run() method, and then simultaneously marks the role as Ready and puts it into the load balancer rotation (if InputEndpoints are defined). 然后,WaHostBootsrapper 进入检查角色状态的循环中。WaHostBootsrapper then goes into a loop of checking the role status.
    2. 完整 IIS Web 角色 :aIISHost 已启动。Full IIS Web Role : aIISHost is started. WaHostBootstrapper 执行 OnStart() 方法。WaHostBootstrapper executes the OnStart() method. 返回后,它开始执行 Run() 方法,同时将角色标记为 Ready,并将其放入负载均衡器轮换阵容。After it returns, it starts to execute the Run() method, and then simultaneously marks the role as Ready and puts it into the load balancer rotation. 然后,WaHostBootsrapper 进入检查角色状态的循环中。WaHostBootsrapper then goes into a loop of checking the role status.
  10. 将 Web 请求传入完整 IIS Web 角色会触发 IIS 来启动 W3WP 进程并为请求提供服务,像在本地 IIS 环境中一样。Incoming web requests to a Full IIS web role triggers IIS to start the W3WP process and serve the request, the same as it would in an on-premises IIS environment.

日志文件位置Log File locations

WindowsAzureGuestAgentWindowsAzureGuestAgent

  • C:\Logs\AppAgentRuntime.Log.C:\Logs\AppAgentRuntime.Log.
    此日志包含对服务所做的更改,包括启动、停止和新建配置。This log contains changes to the service including starts, stops, and new configurations. 如果服务未更改,则你在此日志文件中预期会看到较大的时间差。If the service does not change, you can expect to see large gaps of time in this log file.
  • C:\Logs\WaAppAgent.Log.C:\Logs\WaAppAgent.Log.
    此日志包含状态更新和检测信号通知,每隔 2-3 秒更新一次。This log contains status updates and heartbeat notifications and is updated every 2-3 seconds. 此日志包含实例状态的历史视图,告知实例何时不处于就绪状态。This log contains a historic view of the status of the instance and will tell you when the instance was not in the Ready state.

WaHostBootstrapperWaHostBootstrapper

C:\Resources\Directory\<deploymentID>.<role>.DiagnosticStore\WaHostBootstrapper.log

WaIISHostWaIISHost

C:\Resources\Directory\<deploymentID>.<role>\WaIISHost.log

IISConfiguratorIISConfigurator

C:\Resources\Directory\<deploymentID>.<role>\IISConfigurator.log

IIS 日志IIS logs

C:\Resources\Directory\<guid>.<role>.DiagnosticStore\LogFiles\W3SVC1

Windows 事件日志Windows Event logs

D:\Windows\System32\Winevt\Logs