ASDK 的部署后配置Post deployment configurations for ASDK

安装 Azure Stack 开发工具包 (ASDK) 之后,当你在 ASDK 主计算机上以 AzureStack\AzureStackAdmin 身份登录时,应进行一些建议的部署后配置更改。After you install the Azure Stack Development Kit (ASDK), you should make a few recommended post deployment configuration changes while signed in as AzureStack\AzureStackAdmin on the ASDK host computer.

安装 Azure Stack PowerShellInstall Azure Stack PowerShell

需要安装与 Azure Stack 兼容的 Azure PowerShell 模块才能使用 Azure Stack。Azure Stack compatible Azure PowerShell modules are required to work with Azure Stack.

通过 PowerShell 库安装适用于 Azure Stack 的 PowerShell 命令。PowerShell commands for Azure Stack are installed through the PowerShell Gallery. 若要注册 PSGallery 存储库,请打开权限提升的 PowerShell 会话并运行以下命令:To register the PSGallery repository, open an elevated PowerShell session and run the following command:

Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

使用 API 版本配置文件来指定与 Azure Stack 兼容的 AzureRM 模块。Use API version profiles to specify Azure Stack compatible AzureRM modules. API 版本配置文件提供一种管理 Azure 与 Azure Stack 之间版本差异的方式。API version profiles provide a way to manage version differences between Azure and Azure Stack. API 版本配置文件是一组具有特定 API 版本 AzureRM PowerShell 模块。An API version profile is a set of AzureRM PowerShell modules with specific API versions. 可通过 PowerShell 库获得的 AzureRM.BootStrapper 模块会提供使用 API 版本配置文件所需的 PowerShell cmdlet。The AzureRM.BootStrapper module that's available through the PowerShell Gallery provides PowerShell cmdlets that are required to work with API version profiles.

无论是否与 ASDK 主机建立了 Internet 连接,都可以安装最新 Azure Stack PowerShell 模块:You can install the latest Azure Stack PowerShell module with or without internet connectivity to the ASDK host computer:

Important

在安装所需版本之前,请务必卸载任何现有 Azure PowerShell 模块Before installing the required version, make sure that you uninstall any existing Azure PowerShell modules.

  • 已从 ASDK 主计算机建立 Internet 连接:运行以下 PowerShell 脚本,以在 ASDK 安装中安装以下模块:With an internet connection from the ASDK host computer: Run the following PowerShell script to install these modules on your ASDK installation:

    Get-Module -Name Azs.* -ListAvailable | Uninstall-Module -Force -Verbose
    Get-Module -Name Azure* -ListAvailable | Uninstall-Module -Force -Verbose
    
    # Install the AzureRM.BootStrapper module. Select Yes when prompted to install NuGet
    Install-Module -Name AzureRM.BootStrapper
    
    # Install and import the API Version Profile required by Azure Stack into the current PowerShell session.
    Use-AzureRmProfile -Profile 2019-03-01-hybrid -Force
    Install-Module -Name AzureStack -RequiredVersion 1.8.0
    

    如果安装成功,输出中会显示 AzureRM 和 AzureStack 模块。If the installation is successful, the AzureRM and AzureStack modules are displayed in the output.

  • 未从 ASDK 主计算机建立 Internet 连接:在离线场景中,必须先使用以下 PowerShell 命令,将 PowerShell 模块下载到已建立 Internet 连接的计算机:Without an internet connection from the ASDK host computer: In a disconnected scenario, you must first download the PowerShell modules to a machine that has internet connectivity using the following PowerShell commands:

    $Path = "<Path that is used to save the packages>"
    
    Save-Package `
      -ProviderName NuGet -Source https://www.powershellgallery.com/api/v2 -Name AzureRM -Path $Path -Force -RequiredVersion 2.3.0
    
    Save-Package `
      -ProviderName NuGet -Source https://www.powershellgallery.com/api/v2 -Name AzureStack -Path $Path -Force -RequiredVersion 1.5.0
    

    接下来,将下载的包复制到 ASDK 计算机,将该位置注册为默认存储库,并从此存储库安装 AzureRM 和 AzureStack 模块:Next, copy the downloaded packages to the ASDK computer and register the location as the default repository and install the AzureRM and AzureStack modules from this repository:

    $SourceLocation = "<Location on the development kit that contains the PowerShell packages>"
    $RepoName = "MyNuGetSource"
    
    Register-PSRepository -Name $RepoName -SourceLocation $SourceLocation -InstallationPolicy Trusted
    
    Install-Module AzureRM -Repository $RepoName
    
    Install-Module AzureStack -Repository $RepoName
    

下载 Azure Stack 工具Download the Azure Stack tools

AzureStack-Tools 是托管 PowerShell 模块的 GitHub 存储库,可用于管理资源并将其部署到 Azure Stack。AzureStack-Tools is a GitHub repository that hosts PowerShell modules for managing and deploying resources to Azure Stack. 若要获取这些工具,请克隆 GitHub 存储库,或运行以下脚本来下载 AzureStack-Tools 文件夹:To obtain these tools, clone the GitHub repository or download the AzureStack-Tools folder by running the following script:

# Change directory to the root directory.
cd \

# Enforce usage of TLSv1.2 to download the Azure Stack tools archive from GitHub
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest `
  -Uri https://github.com/Azure/AzureStack-Tools/archive/master.zip `
  -OutFile master.zip

# Expand the downloaded files.
Expand-Archive -Path master.zip -DestinationPath . -Force

# Change to the tools directory.
cd AzureStack-Tools-master

验证 ASDK 安装Validate the ASDK installation

若要确保 ASDK 部署成功,可以遵循以下步骤使用 Test-AzureStack cmdlet:To ensure that your ASDK deployment was successful, use the Test-AzureStack cmdlet by following these steps:

  1. 以 AzureStack\AzureStackAdmin 身份登录到 ASDK 主计算机。Sign in as AzureStack\AzureStackAdmin on the ASDK host computer.
  2. 以管理员身份打开 PowerShell(非 PowerShell ISE)。Open PowerShell as an admin (not PowerShell ISE).
  3. 运行: Enter-PSSession -ComputerName AzS-ERCS01 -ConfigurationName PrivilegedEndpointRun: Enter-PSSession -ComputerName AzS-ERCS01 -ConfigurationName PrivilegedEndpoint
  4. 运行: Test-AzureStackRun: Test-AzureStack

此项测试可能需要几分钟时间才能完成。The tests take a few minutes to complete. 如果安装成功,将返回如下所示的输出:If the installation was successful, the output looks something like:

测试 Azure Stack - 安装成功

如果失败,请遵循故障排除步骤来获取帮助。If there was a failure, follow the troubleshooting steps to get help.

启用多租户Enable multi-tenancy

对于使用 Azure AD 的部署,需要为 ASDK 安装启用多租户For deployments using Azure AD, you need to enable multi-tenancy for your ASDK installation.

Note

当使用非用于注册 Azure Stack 的域的管理员或用户帐户登录 Azure Stack 门户时,用于注册 Azure Stack 的域名必须追加到门户 URL 后面。When admin or user accounts from domains other than the one used to register Azure Stack are used to log in to an Azure Stack portal, the domain name used to register Azure Stack must be appended to the portal URL. 例如,如果 Azure Stack 已注册到 fabrikam.partner.onmschina.cn 并且登录的用户帐户为 admin@contoso.com,则用于登录用户门户的 URL 将为 https://portal.local.azurestack.external/fabrikam.partner.onmschina.cn。For example, if Azure Stack has been registered with fabrikam.partner.onmschina.cn and the user account logging in is admin@contoso.com, the URL to use to log into the user portal would be: https://portal.local.azurestack.external/fabrikam.partner.onmschina.cn.

后续步骤Next steps

将 ASDK 注册到 AzureRegister the ASDK with Azure