Azure Stack Hub 中的 PowerShell 入门Get started with PowerShell in Azure Stack Hub

PowerShell 用于从命令行管理资源。PowerShell is designed for managing and administering resources from the command line. 若要生成使用 Azure 资源管理器模型的自动化工具,可以使用 PowerShell。You can use PowerShell when you want to build automated tools that use the Azure Resource Manager model. 可将 PowerShell 模块定义为一组 PowerShell 函数,用于对特定的区域进行全方面的管理。A PowerShell module can be defined as a set of PowerShell functions that are grouped to manage all aspects of a particular area. 若要使用 Azure Stack Hub,需要能够处理不同的 PowerShell cmdlet 集。To work with Azure Stack Hub, you need to juggle various sets of PowerShell cmdlets.

本文可帮助你熟悉 Azure Stack Hub 中使用的各种 PowerShell 模块。This article helps you orient yourself to the variety of PowerShell modules that are used in Azure Stack Hub. 在 Azure Stack Hub 中使用 PowerShell 时,可与任意四组 API 交互,如下表所示:When you use PowerShell in Azure Stack Hub, you can interact with any of four sets of APIs, as shown in the following table:

APIAPI PowerShell 参考PowerShell reference REST 参考REST reference
全局 Azure 资源管理器Global Azure Resource Manager Azure PowerShell 模块Azure PowerShell modules REST API 浏览器REST API browser
Azure Stack Hub 资源管理器Azure Stack Hub Resource Manager 管理 Azure Stack Hub 中的 API 版本配置文件Manage API version profiles in Azure Stack Hub 管理 Azure Stack Hub 中的 API 版本配置文件Manage API version profiles in Azure Stack Hub
Azure Stack Hub 管理员终结点Azure Stack Hub administrator endpoints Azure Stack Hub 管理模块Azure Stack Hub admin module [REST API 浏览器 - Azure Stack HubREST API browser - Azure Stack Hub](/rest/api/?term=Azure Azure Stack Admin)
Azure Stack Hub 特权终结点Azure Stack Hub privileged endpoint 使用 Azure Stack Hub 中的特权终结点Use the privileged endpoint in Azure Stack Hub

每个接口联系全局 Azure 或 Azure Stack 中心中的资源提供程序。Each interface contacts resource providers in global Azure or Azure Stack Hub. 资源提供程序启用 Azure 功能。Resource providers enable Azure capabilities. 例如,Azure 计算资源提供程序可让你以编程方式访问虚拟机及其支持资源的创建和管理。For example, the Azure Compute resource provider gives you programmatic access to the creation and management of virtual machines and their supporting resources.

资源提供程序不仅提供功能,而且还提供用于管理和配置资源的控件。Resource providers provide both functionality and controls for managing and configuring the resource. 可以使用 Azure 资源管理器以编程方式访问资源提供程序。You can programmatically access the resource providers by using Azure Resource Manager. 然后,界面会提供适用于 PowerShell、Azure CLI 和你自己的 REST 客户端的图面。In turn, the interface provides a surface for PowerShell, the Azure CLI, and your own REST clients.

在何处可以找到 Azure Stack Hub PowerShellWhere to find Azure Stack Hub PowerShell

以下框图显示了 PowerShell 模块集之间的关系。The following block diagram shows the relationships between the sets of PowerShell modules. 在计算机上,可以加载 PowerShell 模块并管理全局 Azure 和 Azure Stack 中心。From your machine, you can load the PowerShell modules and manage both global Azure and Azure Stack Hub.

Azure Stack Hub PowerShell

全球 AzureGlobal Azure

Azure PowerShell 包含一组使用最新版 Azure 资源管理器处理 Azure 资源的 cmdlet。Azure PowerShell contains a set of cmdlets that use the current version of Azure Resource Manager for working with your Azure resources. Azure PowerShell 使用 .NET Standard 版本,这意味着你可以使用 Windows、macOS 和 Linux 上的 PowerShell 版本。Azure PowerShell uses the .NET Standard version, which means that you can use versions of PowerShell with Windows, macOS, and Linux. 还可以在 Azure Cloud Shell 中使用 Azure PowerShell。Azure PowerShell is also available on Azure Cloud Shell. 有关详细信息,请参阅 Azure PowerShell 入门For more information, see Get started with Azure PowerShell.

Azure Stack Hub 资源管理器Azure Stack Hub Resource Manager

Azure Stack Hub PowerShell 提供一组使用旧版 Azure 资源管理器的 cmdlet。Azure Stack Hub PowerShell provides a set of cmdlets that use previous versions of Azure Resource Manager. 这些 cmdlet 与 Azure Stack Hub 中的资源提供程序兼容。These cmdlets are compatible with the resource providers in Azure Stack Hub. Azure Stack Hub 中的每个资源提供程序使用可在全球 Azure 中找到的旧版提供程序。Each resource provider in Azure Stack Hub uses an older version of the provider found in global Azure. 为了帮助协调 Azure Stack Hub 支持的每个提供程序版本,可以使用 API 配置文件。To help you coordinate the version of each provider that's supported by Azure Stack Hub, you can use API profiles. 有关详细信息,请参阅在 Azure Stack Hub 中管理 API 版本配置文件For more information, see Manage API version profiles in Azure Stack Hub.

Azure Stack Hub 管理员Azure Stack Hub administrator

Azure Stack Hub 向云操作员公开一组资源提供程序用于安装和维护 Azure Stack Hub。Azure Stack Hub exposes a set of resource providers to the cloud operator so that the operator can install and maintain Azure Stack Hub. 在全球 Azure 中,这种交互是从用户抽象的,并在后台作为 Azure 的一部分进行处理。In global Azure, this interaction is abstracted from the user and handled behind the scenes as part of Azure. Azure Stack 中心;不过,企业可以支持私有云。With Azure Stack Hub; however, enterprises can support a private cloud. 若要执行这些任务,操作员需要与 Azure Stack Hub 管理 API 交互。To do these tasks, the operator interacts with the Azure Stack Hub Admin APIs. 有关详细信息,请参阅安装适用于 Azure Stack Hub 的 PowerShellFor more information, see Install PowerShell for Azure Stack Hub.

Azure Stack Hub 特权终结点Azure Stack Hub privileged endpoint

对于 Azure Stack Hub 中的操作员活动(例如测试安装和访问日志),操作员可与特权终结点 (PEP) 交互。For operator activities in Azure Stack Hub, such as testing the installation and accessing logs, operators can interact with the privileged endpoint (PEP). PEP 是预先配置的远程 PowerShell 控制台,可为操作员提供刚好足够的访问权限来让他们完成特定的任务。The PEP is a pre-configured remote PowerShell console that gives operators enough access to do specific tasks. 终结点使用 PowerShell Just Enough Administration (JEA) 公开一组受限的 cmdlet。The endpoint uses PowerShell Just Enough Administration (JEA) to expose a restricted set of cmdlets. 有关详细信息,请参阅使用 Azure Stack Hub 中的特权终结点For more information, see Use the privileged endpoint in Azure Stack Hub.

Azure Stack Hub 工具Azure Stack Hub Tools

Azure Stack Hub 在 GitHub 存储库 AzureStack-Tools 中提供了脚本和其他 cmdlet。Azure Stack Hub makes scripts and additional cmdlets available in a GitHub repository, AzureStack-Tools. AzureStack-Tools 托管用于管理资源以及将其部署到 Azure Stack Hub 的 PowerShell 模块。AzureStack-Tools hosts PowerShell modules for managing and deploying resources to Azure Stack Hub. 如果你打算建立 VPN 连接,则可将这些 PowerShell 模块下载到 Azure Stack 开发工具包或基于 Windows 的外部客户端。If you're planning to establish VPN connectivity, you can download these PowerShell modules to the Azure Stack Development Kit, or to a Windows-based external client. 有关详细信息,请访问 AzureStack-Tools 页。For more information, go to the AzureStack-Tools page.

使用 Azure Stack Hub 中的 PowerShellWork with PowerShell in Azure Stack Hub

PowerShell 提供编程的方式来与 Azure 资源管理器交互。PowerShell provides a programmatic way to interact with Azure Resource Manager. 可以使用交互式命令提示符;若要将任务自动化,可以编写脚本。You can work with an interactive command prompt or, if you're automating tasks, you can write scripts.

在长时间使用 Azure Stack Hub PowerShell 的过程中,你会发现需要反复安装模块。If you spend much time working with Azure Stack Hub PowerShell, you'll find yourself installing and reinstalling the modules. 如果你同时使用全局 Azure,此例程可能会很困难,因为你需要卸载并重新安装模块,具体取决于你的目标。If you're working with global Azure at the same time, this routine can be challenging, because you'll need to uninstall and reinstall your modules depending on your target.

可以使用 Docker 容器来隔离本地计算机上的每个 PowerShell 版本。You can use Docker containers to isolate each version of PowerShell on your local machine. 若要使用 Docker 容器以便在不同的 PowerShell 模块集之间切换,请参阅使用 Docker 运行 PowerShellTo use Docker containers so that you can switch from PowerShell module set to PowerShell module set, see Use Docker to run PowerShell.

后续步骤Next steps