在 Azure Stack Hub 中设置开发环境Set up a development environment in Azure Stack Hub

可以使用 Windows 10、Linux 或 macOS 工作站开发适用于 Azure Stack Hub 的应用程序。You can develop applications for Azure Stack Hub by using a Windows 10, Linux, or macOS workstation. 本文介绍:In this article, we look at:

  • 应用在 Azure Stack Hub 中运行时所处的各种上下文。The various contexts in which your app runs in Azure Stack Hub.
  • 使用 Windows 10、Linux 或 macOS 工作站进行设置时可以遵循的步骤。The steps to follow to get you set up with a Windows 10, Linux, or macOS workstation.
  • 在 Azure Stack Hub 中创建资源并将其部署到应用的步骤。The steps for creating resources in Azure Stack Hub and deploy them to an app.

Azure Stack Hub 上下文和代码Azure Stack Hub context and your code

可以编写脚本和应用,以在 Azure Stack Hub 中完成多种任务。You can write scripts and apps to accomplish many tasks in Azure Stack Hub. 但是,将范围限制为以下三种模式很有帮助:However, it's helpful to limit your scope to the following three modes:

  1. 在第一种模式下,可以使用 Azure 资源管理器模板创建应用,用于在 Azure Stack Hub 中预配资源。In the first mode, you can create apps that provision resources in Azure Stack Hub by using Azure Resource Manager templates. 例如,可以编写一个可以构造 Azure 资源管理器模板的脚本,而该模板又可以创建用于托管应用的虚拟网络和 VM。For example, you might write a script that constructs an Azure Resource Manager template that in turn creates a virtual network and the VMs that will host your app.

  2. 在第二种模式下,可以使用 REST API 和 REST 客户端直接处理在代码中创建的终结点。In the second mode, you work directly with endpoints by using the REST API and a REST client that were created in your code. 在此模式下,可编写一个脚本,以通过将请求发送到 API 来创建虚拟网络和 VM。In this mode, you would write a script that creates a virtual network and the VMs by sending requests to the APIs.

  3. 在第三种模式下,可以使用代码创建托管在 Azure Stack Hub 中的应用。In the third mode, you can use your code to create an app that's hosted in Azure Stack Hub. 在 Azure Stack Hub 中创建用于托管应用的基础结构后,将应用部署到该基础结构。After you've created the infrastructure in Azure Stack Hub for hosting your app, you deploy your app to the infrastructure. 一般情况下,你会先准备好环境,然后将应用部署到该环境。Ordinarily, you'll prepare your environment and then deploy your app to it.

基础结构即服务和平台即服务Infrastructure as a service and platform as a service

作为一款云平台产品,Azure Stack Hub 支持:As a cloud platform product, Azure Stack Hub supports both:

  • 基础结构即服务 (IaaS)Infrastructure as a service (IaaS)
  • 平台即服务 (PaaS)Platform as a service (PaaS)

IaaS 和 PaaS 都会告知如何设置开发计算机。Both IaaS and PaaS inform how to set up your development machine.

IaaS 是数据中心内的网络设备、网络和服务器等部件的虚拟化。IaaS is the virtualization of the parts of the datacenter that come from network gear, the network, and servers. 将应用部署到托管 Web 服务器的 VM 时,将在 IaaS 模型中操作。When you deploy an app to a VM that hosts the web server, you're working in an IaaS model. 在此模型中,Azure Stack Hub 管理虚拟设备,而应用位于虚拟服务器上。In this model, Azure Stack Hub manages the virtual gear, and your app is on a virtual server. Azure Stack Hub 资源提供程序支持网络组件和虚拟服务器。Azure Stack Hub resource providers support network components and virtual servers.

PaaS 将基础结构层抽象化,因此,你可以将应用部署到随后会运行该应用的终结点。PaaS abstracts the infrastructure layer so that you deploy your app to an endpoint that then runs the app. 在 PaaS 模型中,可以使用容器来托管应用,然后将容器化的应用部署到运行容器的服务。In the PaaS model, you might use containers to host your app and then deploy the containerized app to a service that runs the container. 或者,可以直接将应用推送到运行应用的服务。Or you might push your app directly to a service that runs the app. 可以使用 Azure Stack Hub 来运行 Azure 应用服务和 Kubernetes。You can use Azure Stack Hub to run Azure App Service and Kubernetes.

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

上述三种模式以及 PaaS 或 IaaS 由 Azure Stack Hub 版的 Azure 资源管理器启用。The three previously mentioned modes, as well as PaaS or IaaS, are enabled by the Azure Stack Hub version of Azure Resource Manager. 使用此管理框架可以部署、管理和监视 Azure Stack Hub 资源。This management framework allows you to deploy, manage, and monitor Azure Stack Hub resources. 该框架允许在单个操作中以组的形式使用资源。It lets you work with the resources as a group in a single operation. 有关使用 Azure Stack Hub 资源管理器的详细信息,请参阅管理 Azure Stack Hub 中的 API 版本配置文件For more information about working with the Azure Stack Hub Resource Manager, see Manage API version profiles in Azure Stack Hub.

Azure Stack Hub SDKAzure Stack Hub SDKs

Azure Stack Hub 使用 Azure Stack Hub 版的 Azure 资源管理器。Azure Stack Hub uses an Azure Stack Hub version of Azure Resource Manager. 为了帮助你通过所选代码使用 Azure Stack Hub 资源管理器,我们提供了许多 SDK,包括:To help you work with the Azure Stack Hub Resource Manager by using your code of choice, we've provided a number of SDKs, including:

开始之前Before you start

在开始设置环境之前,需要:Before you begin setting up your environment, you need:

  • Azure Stack Hub 用户门户的访问权限。Access to the Azure Stack Hub user portal.
  • 租户的名称。The name of your tenant.
  • 确定是使用 Azure Active Directory (Azure AD) 还是 Active Directory 联合身份验证服务 (AD FS) 作为标识管理器。To determine whether you're using Azure Active Directory (Azure AD) or Active Directory Federation Services (AD FS), as your identity manager.

如果遇到 Azure Stack Hub 方面的任何问题,请与云运营商联系。If you have any questions about Azure Stack Hub, contact your cloud operator.

Windows 10Windows 10

在 Windows 10 计算机上,可以使用 PowerShell 5.0 和 Visual Studio。If you're using a Windows 10 machine, you can work with PowerShell 5.0 and Visual Studio. 如果使用的是 Azure Stack 开发工具包 (ASDK),请通过 VPN 连接环境。And if you're working with an Azure Stack Development Kit (ASDK), you can connect to your environment with a VPN connection.

设置工具Set up your tools

  1. 使用 PowerShell 进行设置。Get set up with PowerShell. 有关说明,请参阅安装 Azure Stack Hub PowerShellFor instructions, see Install Azure Stack Hub Powershell.

  2. 下载 Azure Stack Hub 工具。Download Azure Stack Hub Tools. 有关说明,请参阅从 GitHub 下载 Azure Stack Hub 工具For instructions, see Download Azure Stack Hub tools from GitHub.

  3. 如果使用的是 ASDK,请安装并配置 Azure Stack Hub 的 VPN 连接If you're using an ASDK, install and configure a VPN connection to Azure Stack Hub.

  4. 安装并配置 Azure CLI。Install and configure the Azure CLI. 有关说明,请参阅在 Azure Stack Hub 中将 API 版本配置文件与 Azure CLI 配合使用For instructions, see Use API version profiles with the Azure CLI in Azure Stack Hub.

  5. 安装并配置设置 Azure 存储资源管理器。Install and configure Azure Storage Explorer. 存储资源管理器是可用于处理 Azure Stack Hub 存储数据的独立应用。Storage Explorer is a standalone app that enables you to work with Azure Stack Hub storage data. 有关说明,请参阅将存储资源管理器连接到 Azure Stack Hub 订阅或存储帐户For instructions, see Connect Storage Explorer to an Azure Stack Hub subscription or a storage account.

安装集成开发环境Install your integrated development environment

  1. 根据代码基和偏好安装集成开发环境 (IDE)。Install your integrated development environment (IDE), depending on your code base and preference.

  2. 为代码安装 SDK:Install the SDK for your code:

LinuxLinux

在 Linux 计算机上,可以使用 Azure CLI 和 Visual Studio Code,或自己偏好的集成开发环境。If you're using a Linux machine, you can work with the Azure CLI, Visual Studio Code, or your own preferred integrated development environment.

备注

如果使用包含 ASDK 的 Linux 计算机,则远程计算机需位于 ASDK 所在的同一网络。If you're using a Linux machine with the ASDK, your remote machine needs to be in the same network as the ASDK. 无法使用虚拟专用网连接进行连接。You won't be able to connect using a Virtual Private Network connection.

设置工具Set up your tools

  1. 安装并配置 Azure CLI。Install and configure the Azure CLI. 有关说明,请参阅在 Azure Stack Hub 中将 API 版本配置文件与 Azure CLI 配合使用For instructions, see Use API version profiles with the Azure CLI in Azure Stack Hub.

  2. 安装并配置设置 Azure 存储资源管理器。Install and configure Azure Storage Explorer. 存储资源管理器是可用于处理 Azure Stack Hub 存储数据的独立应用。Storage Explorer is a standalone app that enables you to work with Azure Stack Hub storage data. 有关说明,请参阅将存储资源管理器连接到 Azure Stack Hub 订阅或存储帐户For instructions, see Connect Storage Explorer to an Azure Stack Hub subscription or a storage account.

安装集成开发环境Install your integrated development environment

  1. 根据代码基和偏好安装集成开发环境 (IDE)。Install your integrated development environment (IDE), depending on your code base and preference.

  2. 为代码安装 SDK:Install the SDK for your code:

macOSmacOS

在 macOS 计算机中可以使用 Azure CLI 和 Visual Studio Code,或自己偏好的集成开发环境。A macOS machine will allow you to work with the Azure CLI and Visual Studio Code, or your own preferred integrated development environment.

备注

如果使用包含 ASDK 的 macOS 计算机,则远程计算机需位于 ASDK 所在的同一网络。If you're using a macOS machine with the ASDK, your remote machine needs to be in the same network as the ASDK. 无法使用虚拟专用网连接进行连接。You won't be able to connect using a Virtual Private Network connection.

设置工具Set up your tools

  1. 安装并配置 Azure CLI。Install and configure the Azure CLI. 有关说明,请参阅在 Azure Stack Hub 中将 API 版本配置文件与 Azure CLI 配合使用For instructions, see Use API version profiles with the Azure CLI in Azure Stack Hub.

  2. 安装并配置设置 Azure 存储资源管理器。Install and configure Azure Storage Explorer. 存储资源管理器是可用于处理 Azure Stack Hub 存储数据的独立应用。Storage Explorer is a standalone app that enables you to work with Azure Stack Hub storage data. 有关说明,请参阅将存储资源管理器连接到 Azure Stack Hub 订阅或存储帐户For instructions, see Connect Storage Explorer to an Azure Stack Hub subscription or a storage account.

安装集成开发环境Install your integrated development environment

  1. 根据代码基和偏好安装集成开发环境 (IDE)。Install your integrated development environment (IDE), depending on your code base and preference.

  2. 为代码安装 SDK:Install the SDK for your code:

后续步骤Next steps

若要将应用部署到 Azure Stack Hub 中的资源,请参阅 Azure Stack Hub 的常见部署To deploy an app to resources in Azure Stack Hub, see Common deployments for Azure Stack Hub.