了解 Windows Admin Center 扩展Understanding Windows Admin Center Extensions

适用于:Windows Admin Center、Windows Admin Center 预览版Applies To: Windows Admin Center, Windows Admin Center Preview

如果你尚不熟悉 Windows 管理中心中心的工作方式,让我们从高级体系结构开始。In case you're not yet familiar with how Windows Admin Center works, let's start with the high-level architecture. Windows Admin Center 由两个主要组件构成:Windows Admin Center is comprised of two main components:

  • 轻型 Web 服务,向 Web 浏览器请求提供 Windows Admin Center UI Web 页面。Lightweight web service that serves Windows Admin Center UI web pages to web browser requests.
  • 网关组件,侦听来自 Web 页面的 REST API 请求并中继要在目标服务器或群集上执行的 WMI 调用或 PowerShell 脚本。Gateway component that listens for REST API requests from the web pages and relays WMI calls or PowerShell scripts to be executed on a target server or cluster.

Windows Admin Center 体系结构

Web 服务提供的 Windows Admin Center UI Web 页面从可扩展性角度有两个主要 UI 组件:解决方案和工具,其作为扩展实现,以及第三个称为网关插件的扩展类型。The Windows Admin Center UI web pages served by the web service has two main UI components from an extensibility perspective, solutions and tools, which are implemented as extensions, and, a third extension type called gateway plugins.

解决方案扩展Solution extensions

在 Windows Admin Center 主屏幕中,默认情况下,你可以添加四个类型之一的连接 - Windows Server 连接、Windows 电脑连接、故障转移群集连接和超融合群集连接。In the Windows Admin Center home screen, by default, you can add connections that are one of four types – Windows Server connections, Windows PC connections, failover cluster connections and hyper-converged cluster connections. 添加连接后,将在主屏幕中显示连接名称和类型。Once a connection is added, the connection name and type will be displayed in the home screen. 单击连接名称将尝试连接到目标服务器或群集,然后加载连接的 UI。Clicking on the connection name will attempt to connect to the target server or cluster and then load the UI for the connection.

Windows Admin Center 体系结构

这个连接类型的每个类型均映射到一个解决方案,解决方案通过“解决方案”扩展扩展类型定义。Each of these connection types map to a solution and solutions are defined through a type of extension called “solution” extensions. 解决方案通常定义你希望通过 Windows Admin Center 管理的唯一对象类型,如服务器、电脑或故障转移群集。Solutions typically define a unique type of object you wish to manage through Windows Admin Center, such as servers, PCs or failover clusters. 你还可以定义用于连接到并管理其他设备(如网络交换机和 Linux 服务器)的新解决方案,甚至是像远程桌面服务这样的服务。You could also define a new solution for connecting to and managing other devices such as network switches and Linux servers, or even services such as Remote Desktop Services.

工具扩展Tool extensions

在单击 Windows Admin Center 主屏幕中的连接并连接时,所选连接类型的解决方案扩展将加载,然后将向你呈现解决方案 UI,并在左侧导航窗格中显示工具列表。When you click on a connection in the Windows Admin Center home screen and connect, the solution extension for the selected connection type will be loaded and you will then be presented with the solution UI including a list of tools in the left navigation pane. 在你单击工具时,工具 UI 将加载并在右侧窗格中显示。When you click on a tool, the tool UI is loaded and displayed in the right pane.

Windows Admin Center UI 体系结构

这些工具中的每一个均通过第二个扩展类型“工具”扩展定义。Each of these tools are defined through a second type of extension called “tool” extensions. 在加载工具时,它可以在目标服务器或群集上执行 WMI 调用或 PowerShell 脚本,并可以基于用户输入在 UI 中显示信息或执行命令。When a tool is loaded, it can execute WMI calls or PowerShell scripts on a target server or cluster and display information in the UI or execute commands based on user input. 工具扩展定义它应为其显示的解决方案,因此每个解决方案的工具集会不同。A tool extension defines which solutions it should be displayed for, resulting in a different set of tools for each solution. 如果你在创建新的解决方案扩展,你额外还需要编写一个或多个为解决方案提供功能的工具扩展。If you are creating a new solution extension, you'll additionally need to write one or more tool extensions that provide functionality for the solution.

每个解决方案的工具列表

网关插件Gateway plugins

网关服务公开 UI 的 REST API 来调用和中继要在目标上执行的命令和脚本。The gateway service exposes REST APIs for the UI to call and relays commands and scripts to be executed on the target. 网关服务可以由支持不同协议的网关插件扩展。The gateway service can be extended by gateway plugins that support different protocols. Windows Admin Center 预打包了两个网关插件,一个用于执行 PowerShell 脚本,另一个用于执行 WMI 命令。Windows Admin Center is pre-packaged with two gateway plugins, one for executing PowerShell scripts and the other for WMI commands. 如果你需要通过 PowerShell 或 WMI 以外的协议(如 REST)与目标通信,则可以为此构建网关插件。If you need to communicate with the target through a protocol other than PowerShell or WMI, such as REST, you can build a gateway plugin for this.

后续步骤Next steps

根据你想要在 Windows Admin Center 中构建的功能,为现有服务器或群集解决方案构建工具扩展可能已经足够,并且是构建扩展最简单的第一步。Depending on what capabilities you want to build in Windows Admin Center, building a tool extension for an existing server or cluster solution may be sufficient, and is the easiest first step into building extensions. 但是,如果你的功能是用于管理设备、服务或一些全新内容,而不是服务器或群集,则应考虑使用一个或多个工具构建解决方案扩展However, if your feature is for managing a device, service or something completely new, rather than a server or cluster, you should consider building a solution extension with one or more tools. 最后,如果需要通过 WMI 或 PowerShell 以外的协议与目标通信,则需要构建网关插件And finally, if you need to communicate with the target through a protocol other than WMI or PowerShell, you'll need to build a gateway plugin. 继续阅读,了解如何设置开发环境以及开始编写你的第一个扩展。Continue reading on to learn how to set up your development environment and start writing your first extension.