使用 Powershell 从命令行部署 ASDKDeploy ASDK from the command line using Powershell

Azure Stack 开发工具包 (ASDK) 是一个测试和开发环境,可以在部署后用来评估和演示 Azure Stack 功能和服务。The Azure Stack Development Kit (ASDK) is a testing and development environment that you can deploy to evaluate and demonstrate Azure Stack features and services. 若要启动并运行该工具包,需要准备环境硬件并运行一些脚本。To get it up and running, you need to prepare the environment hardware and run some scripts. 这些脚本需要几个小时才能完成运行。The scripts take several hours to run. 之后便可以登录到管理员门户和用户门户,开始使用 Azure Stack。After that, you can sign in to the admin and user portals to start using Azure Stack.

先决条件Prerequisites

准备 ASDK 主机。Prepare the ASDK host computer. 计划硬件、软件和网络。Plan your hardware, software, and network. 托管 ASDK 的计算机必须符合硬件、软件与网络要求。The computer that hosts the ASDK must meet hardware, software, and network requirements. 选择是使用 Azure Active Directory (Azure AD) 还是使用 Active Directory 联合身份验证服务 (AD FS)。Choose between using Azure Active Directory (Azure AD) or Active Directory Federation Services (AD FS). 请务必在开始部署之前符合这些先决条件,以便安装进程能顺利运行。Be sure to follow these prerequisites before starting your deployment so that the installation process runs smoothly.

在部署 ASDK 之前,请确保计划的 ASDK 主机的硬件、操作系统、帐户和网络配置符合安装 ASDK 所需的最低要求。Before you deploy the ASDK, make sure your planned ASDK host computer's hardware, operating system, account, and network configurations meet the minimum requirements for installing the ASDK.

查看 ASDK 部署要求和注意事项Review the ASDK deployment requirements and considerations.

Tip

安装操作系统以后,可以使用 Azure Stack 部署要求检查工具来确认硬件是否满足所有要求。You can use the Azure Stack deployment requirements check tool after installing the operating system to confirm that your hardware meets all requirements.

下载并提取部署包Download and extract the deployment package

在确保 ASDK 主机满足安装 ASDK 的基本要求以后,下一步是下载并提取 ASDK 部署包。After ensuring that your ASDK host computer meets the basic requirements for installing the ASDK, the next step is to download and extract the ASDK deployment package. 部署包包括 Cloudbuilder.vhdx 文件,该文件是一个虚拟硬盘驱动器,其中包括一个可启动的操作系统,以及 Azure Stack 安装文件。The deployment package includes the Cloudbuilder.vhdx file, which is a virtual hard drive that includes a bootable operating system and the Azure Stack installation files.

可以将部署包下载到 ASDK 主机或另一台计算机。You can download the deployment package to the ASDK host or to another computer. 提取的部署文件占用 60 GB 的可用磁盘空间,因此使用另一台计算机有助于减少 ASDK 主机的硬件要求。The extracted deployment files take up 60 GB of free disk space, so using another computer can help reduce the hardware requirements for the ASDK host.

下载并提取 Azure Stack 开发工具包 (ASDK)Download and extract the Azure Stack Development Kit (ASDK)

准备 ASDK 主机Prepare the ASDK host computer

必须先准备环境并将系统配置为从 VHD 启动,然后才能在主机上安装 ASDK。Before you can install the ASDK on the host computer, the environment must be prepared and the system configured to boot from VHD. 此步骤完成后,ASDK 主机将启动到 Cloudbuilder.vhdx(一个包含可启动操作系统和 Azure Stack 安装文件的虚拟硬盘)。After this step, the ASDK host will boot to the Cloudbuilder.vhdx (a virtual hard drive that includes a bootable operating system and the Azure Stack installation files).

使用 PowerShell 将 ASDK 主机配置为从 CloudBuilder.vhdx 启动。Use PowerShell to configure the ASDK host computer to boot from CloudBuilder.vhdx. 以下命令会将 ASDK 主机配置为从下载后提取的 Azure Stack 虚拟硬盘 (CloudBuilder.vhdx) 启动。These commands configure your ASDK host computer to boot from the downloaded and extracted Azure Stack virtual harddisk (CloudBuilder.vhdx). 完成这些步骤后,请重启 ASDK 主机。After completing these steps, restart the ASDK host computer.

若要将 ASDK 主机配置为从 CloudBuilder.vhdx 启动,请执行以下操作:To configure the ASDK host computer to boot from CloudBuilder.vhdx:

  1. 以管理员身份启动命令提示符。Launch a command prompt as admin.
  2. 运行 bcdedit /copy {current} /d "Azure Stack"Run bcdedit /copy {current} /d "Azure Stack".
  3. 复制 (CTRL+C) 返回的 CLSID 值,包括必需的大括号 ({})。Copy (CTRL+C) the CLSID value returned, including the required curly brackets ({}). 该值以 {CLSID} 的形式引用,需要在余下的步骤中粘贴进去(CTRL+V 或右键单击)。This value is referred to as {CLSID} and needs to be pasted in (CTRL+V or right-click) in the remaining steps.
  4. 运行 bcdedit /set {CLSID} device vhd=[C:]\CloudBuilder.vhdxRun bcdedit /set {CLSID} device vhd=[C:]\CloudBuilder.vhdx.
  5. 运行 bcdedit /set {CLSID} osdevice vhd=[C:]\CloudBuilder.vhdxRun bcdedit /set {CLSID} osdevice vhd=[C:]\CloudBuilder.vhdx.
  6. 运行 bcdedit /set {CLSID} detecthal onRun bcdedit /set {CLSID} detecthal on.
  7. 运行 bcdedit /default {CLSID}Run bcdedit /default {CLSID}.
  8. 若要验证启动设置,请运行 bcdeditTo verify boot settings, run bcdedit.
  9. 确保已将 CloudBuilder.vhdx 文件移动到 C:\ 驱动器的根目录 (C:\CloudBuilder.vhdx),并重启 ASDK 主机。Ensure that the CloudBuilder.vhdx file has been moved to the root of the C:\ drive (C:\CloudBuilder.vhdx) and restart the ASDK host computer. 重启 ASDK 主机时,该主机应该从 CloudBuilder.vhdx 虚拟机 (VM) 硬盘启动,然后开始进行 ASDK 部署。When the ASDK host computer is restarted, it should boot from the CloudBuilder.vhdx virtual machine (VM) hard drive to begin ASDK deployment.

Important

确保可以直接通过物理方式或 KVM 方式访问 ASDK 主机,然后再重启它。Ensure that you have direct physical or KVM access to the ASDK host computer before restarting it. VM 在第一次启动时会提示你完成 Windows Server 设置。When the VM first starts, it prompts you to complete Windows Server Setup. 提供用于登录到 ASDK 主机的相同管理员凭据。Provide the same admin credentials you used to log into the ASDK host computer.

使用 PowerShell 准备 ASDK 主机Prepare the ASDK host using PowerShell

在 ASDK 主机成功启动进入 CloudBuilder.vhdx 映像之后,请使用用于登录到 ASDK 主机的相同本地管理员凭据登录。After the ASDK host computer successfully boots into the CloudBuilder.vhdx image, sign in with the same local admin credentials you used to log into the ASDK host computer. 这些凭据也是在主机从 VHD 启动后完成 Windows Server 安装过程中所提供的相同凭据。These are also the same credentials you provided as part of completing the Windows Server Setup when the host computer booted from VHD.

Note

也可在安装 ASDK 之前配置 Azure Stack 遥测设置Optionally, you can also configure Azure Stack telemetry settings before installing the ASDK.

打开提升了权限的 PowerShell 控制台并运行此部分的命令,以便在 ASDK 主机上部署 ASDK。Open an elevated PowerShell console and run the commands in this section to deploy the ASDK on the ASDK host.

Important

ASDK 安装支持使用一个网络接口卡 (NIC) 进行网络连接。ASDK installation supports exactly one network interface card (NIC) for networking. 如果有多个 NIC,请确保只启用一个(所有其他 NIC 均禁用),然后再运行部署脚本。If you have multiple NICs, make sure that only one is enabled (and all others are disabled) before running the deployment script.

可以将 Azure AD 或 Windows Server AD FS 作为标识提供者来部署 Azure Stack。You can deploy Azure Stack with Azure AD or Windows Server AD FS as the identity provider. Azure Stack、资源提供程序和其他应用使用这二者的方式是相同的。Azure Stack, resource providers, and other apps work the same way with both.

Tip

如果不提供任何安装参数(参见下面的 InstallAzureStackPOC.ps1 可选参数和示例),系统会提示输入必需的参数。If you don't supply any setup parameters (see InstallAzureStackPOC.ps1 optional parameters and examples below), you're prompted for the required parameters.

使用 Azure AD 部署 Azure StackDeploy Azure Stack using Azure AD

若要使用 Azure AD 作为标识提供者来部署 Azure Stack,必须通过直接方式或透明代理方式建立 Internet 连接。To deploy Azure Stack using Azure AD as the identity provider, you must have internet connectivity either directly or through a transparent proxy.

运行以下 PowerShell 命令,以便使用 Azure AD 部署 ASDK:Run the following PowerShell commands to deploy the ASDK using Azure AD:

cd C:\CloudDeployment\Setup     
$adminpass = Get-Credential Administrator     
.\InstallAzureStackPOC.ps1 -AdminPassword $adminpass.Password

进行 ASDK 安装后数分钟,系统会提示输入 Azure AD 凭据。A few minutes into ASDK installation you'll be prompted for Azure AD credentials. 提供 Azure AD 租户的全局管理员凭据。Provide the global admin credentials for your Azure AD tenant.

部署后,不需要 Azure Active Directory 全局管理员权限。After deployment, Azure Active Directory global admin permission isn't required. 但是,某些操作可能需要全局管理员凭据。However, some operations may require the global admin credential. 此类操作的示例包括资源提供程序安装程序脚本或需要授予权限的新功能。Examples of such operations include a resource provider installer script or a new feature requiring a permission to be granted. 可以临时复原帐户的全局管理员权限,也可以使用单独的全局管理员帐户(该帐户应是默认提供程序订阅的所有者)。You can either temporarily reinstate the account's global admin permissions or use a separate global admin account that's an owner of the default provider subscription.

使用 AD FS 部署 Azure StackDeploy Azure Stack using AD FS

若要使用 AD FS 作为标识提供者来部署 ASDK,请运行以下 PowerShell 命令(只需添加 -UseADFS 参数):To deploy the ASDK using AD FS as the identity provider, run the following PowerShell commands (you just need to add the -UseADFS parameter):

cd C:\CloudDeployment\Setup     
$adminpass = Get-Credential Administrator 
.\InstallAzureStackPOC.ps1 -AdminPassword $adminpass.Password -UseADFS

在 AD FS 部署中,默认的标记目录服务用作标识提供者。In AD FS deployments, the default stamp Directory Service is used as the identity provider. 登录时使用的默认帐户是 azurestackadmin@azurestack.local,而密码则会设置为在 PowerShell 安装命令中提供的密码。The default account to sign in with is azurestackadmin@azurestack.local, and the password is set to what you provided as part of the PowerShell setup commands.

部署过程可能需要数小时,在此期间系统会自动重启一次。The deployment process can take a few hours, during which time the system automatically reboots once. 如果部署成功,PowerShell 控制台会显示“COMPLETE: Action 'Deployment'”。When the deployment succeeds, the PowerShell console displays: COMPLETE: Action ‘Deployment'. 如果部署失败,请尝试使用 -rerun 参数再次运行脚本。If the deployment fails, try running the script again using the -rerun parameter. 也可从头开始重新部署 ASDKOr, you can redeploy ASDK from scratch.

Important

若要在 ASDK 主机重启后监视部署进度,必须以 AzureStack\AzureStackAdmin 身份登录。If you want to monitor the deployment progress after the ASDK host reboots, you must sign in as AzureStack\AzureStackAdmin. 如果在主机重启(并加入 azurestack.local 域)后以本地管理员身份登录,将看不到部署进度。If you sign in as a local admin after the host computer is restarted (and joined to the azurestack.local domain), you won't see the deployment progress. 不要重新运行部署,而是以 AzureStack\AzureStackAdmin 身份登录,并使用与本地管理员相同的密码来验证安装程序是否正在运行。Don't rerun deployment, instead sign in as AzureStack\AzureStackAdmin with the same password as the local admin to validate that the setup is running.

Azure AD 部署脚本示例Azure AD deployment script examples

可以编写整个 Azure AD 部署的脚本。You can script the entire Azure AD deployment. 下面是一些加注的示例,其中包括一些可选参数。Here are a few commented examples that include some optional parameters.

如果 Azure AD 标识只与一个 Azure AD 目录相关联,请执行以下代码:If your Azure AD identity is only associated with one Azure AD directory:

cd C:\CloudDeployment\Setup 
$adminpass = Get-Credential Administrator 
$aadcred = Get-Credential "<Azure AD global administrator account name>" 
.\InstallAzureStackPOC.ps1 -AdminPassword $adminpass.Password -InfraAzureDirectoryTenantAdminCredential $aadcred -TimeServer 52.168.138.145 #Example time server IP address.

如果 Azure AD 标识与多个 Azure AD 目录相关联,请执行以下代码:If your Azure AD identity is associated with greater than one Azure AD directory:

cd C:\CloudDeployment\Setup 
$adminpass = Get-Credential Administrator 
$aadcred = Get-Credential "<Azure AD global administrator account name>" #Example: user@AADDirName.partner.onmschina.cn 
.\InstallAzureStackPOC.ps1 -AdminPassword $adminpass.Password -InfraAzureDirectoryTenantAdminCredential $aadcred -InfraAzureDirectoryTenantName "<Azure AD directory in the form of domainname.partner.onmschina.cn or an Azure AD verified custom domain name>" -TimeServer 52.168.138.145 #Example time server IP address.

如果环境没有启用 DHCP,则必须在上述某个选项中包括下述额外的参数(已提供用法示例):If your environment doesn't have DHCP enabled, then you must include the following additional parameters to one of the options above (example usage provided):

.\InstallAzureStackPOC.ps1 -AdminPassword $adminpass.Password -InfraAzureDirectoryTenantAdminCredential $aadcred -TimeServer 10.222.112.26

ASDK InstallAzureStackPOC.ps1 可选参数ASDK InstallAzureStackPOC.ps1 optional parameters

参数Parameter 必需/可选Required/Optional 说明Description
AdminPasswordAdminPassword 必须Required 在 ASDK 部署过程中创建的所有 VM 上,设置本地管理员帐户和所有其他用户帐户。Sets the local admin account and all other user accounts on all the VMs created as part of ASDK deployment. 此密码必须与当前主机上的本地管理员密码匹配。This password must match the current local admin password on the host.
InfraAzureDirectoryTenantNameInfraAzureDirectoryTenantName 必须Required 设置租户目录。Sets the tenant directory. 使用此参数指定一个具体的目录,使 AAD 帐户有权在其中管理多个目录。Use this parameter to specify a specific directory where the AAD account has permissions to manage multiple directories. AAD 租户的 .partner.onmschina.cn 格式的完整名称,或者 Azure AD 验证的自定义域名。Full name of an AAD tenant in the format of .partner.onmschina.cn or an Azure AD verified custom domain name.
TimeServerTimeServer 必须Required 使用此参数指定具体的时间服务器。Use this parameter to specify a specific time server. 必须以有效的时间服务器 IP 地址的形式提供此参数。This parameter must be provided as a valid time server IP address. 不支持服务器名称。Server names aren't supported.
InfraAzureDirectoryTenantAdminCredentialInfraAzureDirectoryTenantAdminCredential 可选Optional 设置 Azure Active Directory 用户名和密码。Sets the Azure Active Directory user name and password. 这些 Azure 凭据必须是组织 ID。These Azure credentials must be an Org ID.
InfraAzureEnvironmentInfraAzureEnvironment 可选Optional 选择 Azure 环境,以便将此 Azure Stack 部署注册到其中。Select the Azure Environment with which you want to register this Azure Stack deployment. 选择“Azure - 中国”。Select Azure - China.
DNSForwarderDNSForwarder 可选Optional 在 Azure Stack 部署过程中会创建 DNS 服务器。A DNS server is created as part of the Azure Stack deployment. 若要允许解决方案中的计算机解析标记外部的名称,请提供现有的基础结构 DNS 服务器。To allow computers inside the solution to resolve names outside of the stamp, provide your existing infrastructure DNS server. 标记内 DNS 服务器将未知的名称解析请求转发至此服务器。The in-stamp DNS server forwards unknown name resolution requests to this server.
RerunRerun 可选Optional 使用此标志重新运行部署。Use this flag to rerun deployment. 将使用所有以前的输入。All previous input is used. 不支持重新输入以前提供的数据,因为已生成多个唯一的值并将其用于部署。Reentering data previously provided isn't supported because several unique values are generated and used for deployment.

执行部署后配置Perform post-deployment configurations

安装 ASDK 之后,建议进行一些安装后检查和配置更改。After installing the ASDK, there are a few recommended post-installation checks and configuration changes that should be made. 使用 test-AzureStack cmdlet 来验证安装是否成功,然后安装 Azure Stack PowerShell 和 GitHub 工具。Validate your installation was installed successfully by using the test-AzureStack cmdlet, then install Azure Stack PowerShell and GitHub tools.

我们建议重置密码过期策略,确保 ASDK 主机的密码不在评估期结束之前过期。We recommend you reset the password expiration policy to make sure that the password for the ASDK host doesn't expire before your evaluation period ends.

Note

也可在安装 ASDK 之后配置 Azure Stack 遥测设置Optionally, you can also configure Azure Stack telemetry settings after installing the ASDK.

ASDK 后部署任务Post ASDK deployment tasks

注册到 AzureRegister with Azure

必须将 Azure Stack 注册到 Azure,以便将 Azure 市场项下载到 Azure Stack。You must register Azure Stack with Azure so that you can download Azure marketplace items to Azure Stack.

将 Azure Stack 注册到 AzureRegister Azure Stack with Azure

后续步骤Next steps

祝贺!Congratulations! 完成这些步骤后,你便获得了一个包含管理员门户和用户门户的 ASDK 环境。After completing these steps, you'll have an ASDK environment with both admin and user portals.

安装 ASDK 后的配置任务Post ASDK installation configuration tasks