使用 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.

PrerequisitesPrerequisites

準備 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.

下載部署套件並解壓縮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.

重要

請先確保您可直接實際存取 ASDK 主機電腦,或可進行 KVM 存取,然後才重新啟動。Ensure that you have direct physical or KVM access to the ASDK host computer before restarting it. 虛擬機器第一次啟動時,會提示您完成 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.

注意

或者,您也可以在安裝 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.

重要

ASDK 安裝支援正好一個網路介面卡 (NIC) 進行網路運作。ASDK installation supports exactly one network interface card (NIC) for networking. 如果您有多個 NIC,在執行部署指令碼之前,請先確定僅啟用一個 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.

提示

如果您未提供任何設定參數 (請參閱 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,您必須具有網際網路連線能力 (直接或透過透明 Proxy)。To deploy Azure Stack using Azure AD as the identity provider, you must have internet connectivity either directly or through a transparent proxy.

使用 Azure AD,執行下列 PowerShell 命令來部署 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.

重要

如果您想要監視部署進度,在 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.onmicrosoft.com 
.\InstallAzureStackPOC.ps1 -AdminPassword $adminpass.Password -InfraAzureDirectoryTenantAdminCredential $aadcred -InfraAzureDirectoryTenantName "<Azure AD directory in the form of domainname.onmicrosoft.com 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. 使用此參數來指定 Azure AD 帳戶有權限管理多重目錄的特定目錄。Use this parameter to specify a specific directory where the Azure AD account has permissions to manage multiple directories. Azure AD 租用戶的完整名稱 (採用 .onmicrosoft.com 形式或 Azure AD 驗證的自訂網域名稱)。Full name of an Azure AD tenant in the format of .onmicrosoft.com 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 認證必須是組織識別碼。These Azure credentials must be an Org ID.
InfraAzureEnvironmentInfraAzureEnvironment 選用Optional 選取您要用來註冊此 Azure Stack 部署的 Azure 環境。Select the Azure Environment with which you want to register this Azure Stack deployment. 選項包括全球 Azure、Azure - 中國、Azure - 美國政府。Options include global Azure, Azure - China, Azure - US Government.
DNSForwarderDNSForwarder 選用Optional DNS 伺服器會在 Azure Stack 部署期間建立。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.

注意

或者,您也可以在「安裝 ASDK 後」,再 設定 Azure Stack 遙測設定Optionally, you can also configure Azure Stack telemetry settings after installing the ASDK.

部署 ASDK 後的工作Post ASDK deployment tasks

向 Azure 註冊Register with Azure

您必須向 Azure 註冊 Azure Stack,如此您才能夠將 Azure Marketplace 項目下載到 Azure StackYou must register Azure Stack with Azure so that you can download Azure Marketplace items to Azure Stack.

向 Azure 註冊 Azure StackRegister Azure Stack with Azure

後續步驟Next steps

恭喜!Congratulations! 完成這些步驟之後,您將會擁有一個具備管理 https://adminportal.local.azurestack.external 入口網站和使用者 https://portal.local.azurestack.external 入口網站的 ASDK 環境。After completing these steps, you'll have an ASDK environment with both admin https://adminportal.local.azurestack.external and user https://portal.local.azurestack.external portals.

ASDK 安裝後設定工作Post ASDK installation configuration tasks