将 Azure Stack Hub 注册到 Azure

将 Azure Stack Hub 注册到 Azure,以便可以从 Azure 下载市场项,并设置向 Microsoft 报告商业数据的功能。 注册 Azure Stack Hub 之后,使用情况会报告给 Azure 商业组件,然后你就可以在用于注册的 Azure 计费订阅 ID 下查看它。

本文中的信息介绍如何向 Azure 注册 Azure Stack Hub 集成系统。 有关向 Azure 注册 ASDK 的信息,请参阅 ASDK 文档中的 Azure Stack Hub 注册

重要

需要注册才能支持完整的 Azure Stack Hub 功能,包括在市场中提供商品。 如果在使用即用即付计费模式时不注册,将违反 Azure Stack Hub 许可条款。 若要了解有关 Azure Stack Hub 许可模型的详细信息,请参阅如何购买页面

注意

对于连接注册,在与注册关联的 Active Directory 目录中创建Microsoft Entra应用程序和关联的服务主体。 此服务主体用于 Azure Stack Hub 市场方案(查看和下载 Azure 市场项目)、上传使用情况数据(如果启用了使用情况报告)、诊断日志收集和远程支持。 删除或更改此应用程序或服务主体会导致这些方案失效并引发警报。 如果它被删除,则可以重新创建,方法是向 Azure 取消注册然后重新注册 Azure Stack Hub。

注意

在线市场联合、诊断日志收集和远程支持对于断开连接的注册不可用。 必须使用离线市场联合

先决条件

在注册之前,请完成以下先决条件部分:

  • 验证凭据。
  • 设置 PowerShell 语言模式。
  • 安装适用于 Azure Stack Hub 的 PowerShell。
  • 下载 Azure Stack Hub 工具。
  • 确定计费模型。
  • 确定唯一注册名称。

验证凭据

将 Azure Stack Hub 注册到 Azure 之前,必须准备好:

  • Azure 订阅的订阅 ID。 注册仅支持 EA、CSP 或 CSP 共享服务订阅。 CSP 需要确定是使用 CSP 订阅还是使用 APSS 订阅

    若要获取 ID,请转到 Azure 门户,并选择“所有服务”>“常规”>“订阅”,从列表中选择要使用的订阅。 在“Essentials”部分中,找到订阅 ID。 最佳做法是,对生产环境和开发环境或测试环境使用单独的订阅。
  • Azure 订阅的订阅 ID。 注册仅支持 EA 订阅。

    若要获取 ID,请转到 Azure 门户,并选择“所有服务”>“常规”>“订阅”,从列表中选择要使用的订阅。 在“Essentials”部分中,找到订阅 ID。 最佳做法是,对生产环境和开发环境或测试环境使用单独的订阅。

注意

德国云订阅目前不受支持。

  • 订阅所有者的帐户用户名和密码。

  • 用户帐户必须有权访问 Azure 订阅并且有权在与该订阅关联的目录中创建标识应用和服务主体。 建议使用最低特权管理将 Azure Stack Hub 注册到 Azure。 若要详细了解如何创建自定义角色定义,以便限制进行注册时对订阅的访问,请参阅为 Azure Stack Hub 创建注册角色

  • 已注册 Azure Stack Hub 资源提供程序(请参阅下面的“注册 Azure Stack Hub 资源提供程序”部分了解详细信息)。

注册后,不需要Microsoft Entra全局管理员权限。 但是,某些操作可能需要全局管理员凭据(例如,资源提供程序安装程序脚本或需要授予权限的新功能)。 可以临时复原帐户的全局管理员权限,也可以使用单独的全局管理员帐户(该帐户应是默认提供程序订阅的所有者)。

注册 Azure Stack Hub 的用户是Microsoft Entra ID 中服务主体的所有者。 只有注册了 Azure Stack Hub 的用户可以修改 Azure Stack Hub 注册。 所有其他用户(即使是全局管理员)都必须通过“访问控制(IAM)”添加到“默认提供程序订阅”。 如果某位非管理员用户不是注册服务主体的所有者,则该用户在尝试注册或重新注册 Azure Stack Hub 时,可能会遇到 403 响应。 403 响应表明用户权限不足,无法完成此操作。

如果没有符合这些要求的 Azure 订阅,可以在这里创建一个免费 Azure 帐户。 注册 Azure Stack Hub 不会对 Azure 订阅收取任何费用。

注意

如果有多个 Azure Stack Hub,最佳做法是将每个 Azure Stack Hub 注册到其自己的订阅。 这样可以更容易地跟踪使用情况。

设置 PowerShell 语言模式

若要成功注册 Azure Stack Hub,必须将 PowerShell 语言模式设置为 FullLanguage。 若要验证当前的语言模式是否设置为 Full,请打开权限提升的 PowerShell 窗口,并运行以下 PowerShell cmdlet:

$ExecutionContext.SessionState.LanguageMode

确保输出返回的是 FullLanguage。 如果返回了其他任何语言模式,则需要在另一台计算机上运行注册,或者将语言模式设置为 FullLanguage,然后才能继续。

安装适用于 Azure Stack Hub 的 PowerShell

使用适用于 Azure Stack Hub 的最新 PowerShell 来注册到 Azure。

如果最新版本尚未安装,请参阅安装适用于 Azure Stack Hub 的 PowerShell

下载 Azure Stack Hub 工具

Azure Stack Hub 工具 GitHub 存储库包含支持 Azure Stack Hub 功能(包括注册功能)的 PowerShell 模块。 在注册过程中,需要导入并使用 Azure Stack Hub 工具存储库中的 RegisterWithAzure.psm1 PowerShell 模块,将 Azure Stack Hub 实例注册到 Azure。

若要确保使用最新版本,请在注册到 Azure 之前删除 Azure Stack Hub 工具的任何现有版本,然后从 GitHub 下载最新版本

注意

还可以使用操作员访问工作站 (OAW) 访问特权终结点 (PEP)、支持方案的管理员门户和 Azure Stack Hub GitHub 工具。 有关详细信息,请参阅 Azure Stack Hub 操作员访问工作站

确定计费模型

连接的部署允许 Azure Stack Hub 连接到 Internet 和 Azure。 还可以使用 Microsoft Entra ID 或 Active Directory 联合身份验证服务 (AD FS) 作为标识存储,并从两种计费模型中进行选择:即用即付或基于容量。 稍后在运行注册脚本时指定计费模型。

使用断开连接的部署,无需连接到 Internet 即可使用 Azure Stack Hub。 使用断开连接部署,你将受限于一个 AD FS 标识存储和基于容量的计费模型。 稍后在运行注册脚本时指定计费模型。

确定唯一注册名称

运行注册脚本时,必须提供唯一的注册名称。 将 Azure Stack Hub 订阅与 Azure 注册关联的简便方法是使用 Azure Stack Hub 云 ID

注意

使用基于容量的计费模型的 Azure Stack Hub 注册将需要在这些年度订阅到期后重新注册时更改唯一名称,除非你删除过期的注册并重新注册到 Azure。

若要确定 Azure Stack Hub 部署的云 ID,请参阅查找云 ID

使用即用即付计费进行注册

执行以下步骤,使用即用即付计费模式将 Azure Stack Hub 注册到 Azure。

注意

所有这些步骤必须在可以访问特权终结点 (PEP) 的计算机上运行。 有关 PEP 的详细信息,请参阅使用 Azure Stack Hub 中的特权终结点

连接的环境可以访问 Internet 和 Azure。 对于这些环境,需将 Azure Stack Hub 资源提供程序注册到 Azure,然后配置计费模式。

  1. 若要向 Azure 注册 Azure Stack Hub 资源提供程序,请以管理员身份启动 PowerShell ISE,然后使用以下 PowerShell cmdlet,并将 EnvironmentName 参数设置为相应的 Azure 订阅类型(请参阅下面的“参数”)。

  2. 添加用于注册 Azure Stack Hub 的 Azure 帐户。 若要添加该帐户,请运行 Connect-AzAccount cmdlet。 系统会提示输入 Azure 帐户凭据。根据帐户的配置,可能需要使用双因素身份验证。

    Connect-AzAccount -EnvironmentName "<environment name>"
    
    参数 说明
    EnvironmentName Azure 云订阅环境名称。 支持的环境名称有 AzureCloud、AzureUSGovernment 或 AzureChinaCloud(如果使用的是中国 Azure 订阅)。

    注意

    如果会话过期、密码已更改,或者你只是想要切换帐户,请在使用 Connect-AzAccount 登录之前运行以下 cmdlet:Remove-AzAccount-Scope Process

  3. 如果有多个订阅,请运行以下命令,选择要使用的那个订阅:

    Get-AzSubscription -SubscriptionID '<Your Azure Subscription GUID>' | Select-AzSubscription
    
  4. 运行以下命令,在 Azure 订阅中注册 Azure Stack Hub 资源提供程序:

    Register-AzResourceProvider -ProviderNamespace Microsoft.AzureStack
    
  5. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-az 目录中的 Registration 文件夹。 使用 PowerShell 导入 RegisterWithAzure.psm1 模块:

    Import-Module .\RegisterWithAzure.psm1
    
  6. 在继续之前,在同一个 PowerShell 会话中,再次验证是否已登录到正确的 Azure PowerShell 上下文(如果没有,请重复步骤 2 和 3)。此上下文是前面在注册 Azure Stack Hub 资源提供程序时所用的 Azure 帐户。 在同一个 PowerShell 会话中运行 Set-AzsRegistration cmdlet:

    $CloudAdminCred = Get-Credential -UserName <Privileged endpoint credentials> -Message "Enter the cloud domain credentials to access the privileged endpoint."
    $RegistrationName = "<unique-registration-name>"
    Set-AzsRegistration `
       -PrivilegedEndpointCredential $CloudAdminCred `
       -PrivilegedEndpoint <PrivilegedEndPoint computer name> `
       -BillingModel PayAsYouUse `
       -RegistrationName $RegistrationName
    

    有关 Set-AzsRegistration cmdlet 的详细信息,请参阅注册参考

该过程需要花费 10 到 15 分钟。 命令完成后,会显示以下消息:“现已使用提供的参数注册并激活环境”。

使用容量计费模型注册

执行以下步骤,使用容量计费模型将 Azure Stack Hub 注册到 Azure。

注意

所有这些步骤必须在可以访问特权终结点 (PEP) 的计算机上运行。 有关 PEP 的详细信息,请参阅使用 Azure Stack Hub 中的特权终结点

连接的环境可以访问 Internet 和 Azure。 对于这些环境,需将 Azure Stack Hub 资源提供程序注册到 Azure,然后配置计费模式。

  1. 若要向 Azure 注册 Azure Stack Hub 资源提供程序,请以管理员身份启动 PowerShell ISE,然后使用以下 PowerShell cmdlet,并将 EnvironmentName 参数设置为相应的 Azure 订阅类型(请参阅下面的“参数”)。

  2. 添加用于注册 Azure Stack Hub 的 Azure 帐户。 若要添加该帐户,请运行 Connect-AzAccount cmdlet。 系统会提示输入 Azure 帐户凭据。根据帐户的配置,可能需要使用双因素身份验证。

    Connect-AzAccount -Environment "<environment name>"
    
    参数 说明
    EnvironmentName Azure 云订阅环境名称。 支持的环境名称有 AzureCloud、AzureUSGovernment 或 AzureChinaCloud(如果使用的是中国 Azure 订阅)。
  3. 如果有多个订阅,请运行以下命令,选择要使用的那个订阅:

    Get-AzSubscription -SubscriptionID '<Your Azure Subscription GUID>' | Select-AzSubscription
    
  4. 运行以下命令,在 Azure 订阅中注册 Azure Stack Hub 资源提供程序:

    Register-AzResourceProvider -ProviderNamespace Microsoft.AzureStack
    
  5. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-az 目录中的 Registration 文件夹。 使用 PowerShell 导入 RegisterWithAzure.psm1 模块:

    Import-Module .\RegisterwithAzure.psm1
    
  6. 在继续之前,在同一个 PowerShell 会话中,再次验证是否已登录到正确的 Azure PowerShell 上下文(如果没有,请重复步骤 2 和 3)。此上下文是在注册 Azure Stack Hub 资源提供程序时所用的 Azure 帐户。 在同一个 PowerShell 会话中运行 Set-AzsRegistration cmdlet:

    $CloudAdminCred = Get-Credential -UserName <Privileged endpoint credentials> -Message "Enter the cloud domain credentials to access the privileged endpoint."
    $RegistrationName = "<unique-registration-name>"
    Set-AzsRegistration `
       -PrivilegedEndpointCredential $CloudAdminCred `
       -PrivilegedEndpoint <PrivilegedEndPoint computer name> `
       -AgreementNumber <EA agreement number> `
       -BillingModel Capacity `
       -RegistrationName $RegistrationName
    

    使用购买容量 SKU 许可证的 EA 协议编号。

    注意

    可以通过将参数设置为 false 来使用 Set-AzsRegistration cmdlet 的 UsageReportingEnabled 参数禁用使用情况报告。

    有关 Set-AzsRegistration cmdlet 的详细信息,请参阅注册参考

使用容量计费模型注册

若要在离线环境(未建立 Internet 连接)中注册 Azure Stack Hub,需要从 Azure Stack Hub 环境获取注册令牌。 然后在可连接到 Azure 的计算机上使用该令牌,并安装适用于 Azure Stack Hub 的 PowerShell。

从 Azure Stack Hub 环境获取注册令牌

  1. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-az 目录中的 Registration 文件夹。 导入 RegisterWithAzure.psm1 模块:

    Import-Module .\RegisterWithAzure.psm1
    
  2. 若要获取注册令牌,请运行以下 PowerShell cmdlet:

    $FilePathForRegistrationToken = "$env:SystemDrive\RegistrationToken.txt"
    $YourCloudAdminCredential = Get-Credential -UserName <Privileged endpoint credentials> -Message "Enter the cloud domain credentials to access the privileged endpoint."
    $RegistrationToken = Get-AzsRegistrationToken -PrivilegedEndpointCredential $YourCloudAdminCredential `
     -UsageReportingEnabled:$false `
     -PrivilegedEndpoint <PrivilegedEndPoint computer name> `
     -BillingModel Capacity `
     -AgreementNumber '<EA agreement number>' `
     -TokenOutputFilePath $FilePathForRegistrationToken
    

    使用购买容量 SKU 许可证的 EA 协议编号。

    有关 Get-AzsRegistrationToken cmdlet 的详细信息,请参阅注册参考

    提示

    注册令牌保存在为 $FilePathForRegistrationToken 指定的文件中。 可以自行更改文件路径或文件名。

  3. 保存此注册令牌,以便在连接 Azure 的计算机上使用。 可以从 $FilePathForRegistrationToken 复制文件或文本。

连接到 Azure 并注册

在连接到 Internet 的计算机上,执行相同的步骤以导入 RegisterWithAzure.psm1 模块,并登录到正确的 Azure PowerShell 上下文。 然后调用 Register-AzsEnvironment。 指定可注册到 Azure 的注册令牌。 如果使用同一 Azure 订阅 ID 注册多个 Azure Stack Hub 实例,请指定唯一的注册名称。

需要注册令牌和唯一令牌名称。

  1. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-az 目录中的 Registration 文件夹。 导入 RegisterWithAzure.psm1 模块:

    Import-Module .\RegisterWithAzure.psm1
    
  2. 然后运行以下 PowerShell cmdlet:

    $RegistrationToken = "<Your Registration Token>"
    $RegistrationName = "<unique-registration-name>"
    Register-AzsEnvironment -RegistrationToken $RegistrationToken -RegistrationName $RegistrationName
    

(可选)可以使用 Get-Content cmdlet 指向包含注册令牌的文件。

需要注册令牌和唯一令牌名称。

  1. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-az 目录中的 Registration 文件夹。 导入 RegisterWithAzure.psm1 模块:

    Import-Module .\RegisterWithAzure.psm1
    
  2. 然后运行以下 PowerShell cmdlet:

    $RegistrationToken = Get-Content -Path '<Path>\<Registration Token File>'
    Register-AzsEnvironment -RegistrationToken $RegistrationToken -RegistrationName $RegistrationName
    

注意

保存注册资源名称和注册令牌,供以后参考。

从 Azure 注册资源检索激活密钥

接下来,需要在执行 Register-AzsEnvironment 期间,从 Azure 中创建的注册资源检索激活密钥。

若要获取激活密钥,请运行以下 PowerShell cmdlet:

$RegistrationResourceName = "<unique-registration-name>"
$KeyOutputFilePath = "$env:SystemDrive\ActivationKey.txt"
$ActivationKey = Get-AzsActivationKey -RegistrationName $RegistrationResourceName -KeyOutputFilePath $KeyOutputFilePath

提示

激活密钥保存在为 $KeyOutputFilePath 指定的文件中。 可以自行更改文件路径或文件名。

在 Azure Stack Hub 中创建激活资源

使用 Get-AzsActivationKey 从创建的激活密钥中获取文件或文本后,返回到 Azure Stack Hub 环境。 接下来,使用该激活密钥在 Azure Stack Hub 中创建激活资源。 若要创建激活资源,请运行以下 PowerShell cmdlet:

# Open the file that contains the activation key (from Azure), copy the entire contents into your clipboard, then within your PowerShell session (that will communicate with the PEP), paste the activation key contents into a string variable, enclosed by quotation marks: 
$ActivationKey = "<paste activation key here>"
$YourPrivilegedEndpoint = "<privileged_endpoint_computer_name>"
New-AzsActivationResource -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint -ActivationKey $ActivationKey

(可选)可以使用 Get-Content cmdlet,使之指向包含注册令牌的文件:

$ActivationKey = Get-Content -Path '<Path>\<Activation Key File>'
$YourPrivilegedEndpoint = "<privileged_endpoint_computer_name>"
New-AzsActivationResource -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint -ActivationKey $ActivationKey

验证 Azure Stack Hub 注册

可以使用“区域管理”磁贴验证 Azure Stack Hub 注册是否成功。 可在管理员门户的默认仪表板上使用此磁贴。 状态可能是已注册,也可能是未注册。 如果是已注册,则还会显示用于注册 Azure Stack Hub 的 Azure 订阅 ID,以及注册资源组和名称。

  1. 登录到 Azure Stack Hub 管理员门户 https://adminportal.local.azurestack.external

  2. 在“仪表板”中,选择“区域管理”。

  3. 选择“属性”。 此边栏选项卡显示环境的状态和详细信息。 状态可能是“已注册”、“未注册”或“已过期”。

    Azure Stack Hub 管理员门户中的“区域管理”磁贴

    如果已注册,则属性包括:

    • 注册订阅 ID:已注册并与 Azure Stack Hub 关联的 Azure 订阅 ID。
    • 注册资源组:包含 Azure Stack Hub 资源的关联订阅中的 Azure 资源组。
  4. 可以使用 Azure 门户查看 Azure Stack Hub 注册资源,然后验证注册是否成功。 使用已关联到用于注册 Azure Stack Hub 的订阅的帐户登录到 Azure 门户。 选择“所有资源”,启用“显示隐藏类型”复选框,然后选择注册名称。

  5. 如果注册未成功,则必须按照此处的步骤重新注册以解决问题。

或者,可以使用“市场管理”功能来验证注册是否成功。 如果在“市场管理”边栏选项卡中看到市场项列表,即表示注册成功。 但是,在离线环境中,无法在“市场管理”中看到市场项。

续订或更改注册

在以下情况下,需要更新注册:

  • 续订基于容量的年度订阅之后。
  • 更改计费模式时。
  • 基于容量的计费的规模更改(添加/删除节点)时。

注意

如果启用了主动日志收集,并且续订或更改了 Azure Stack Hub 注册,则必须重新启用主动日志收集。 有关主动日志收集的详细信息,请参阅诊断日志收集

先决条件

若要续订或更改注册,需要管理员门户中的以下信息:

管理员门户 Cmdlet 参数 注释
注册订阅 ID 订阅 上一次注册期间使用的订阅 ID
注册资源组 ResourceGroupName 以前的注册资源所在的资源组
注册名称 RegistrationName 上一次注册期间使用的注册名称

更改使用的订阅

若要更改使用的订阅,必须先运行 Remove-AzsRegistration cmdlet,并确保登录到正确的 Azure PowerShell 上下文。 然后使用任何已更改的参数(包括 <billing model>)运行 Set-AzsRegistration。 运行 Remove-AzsRegistration 时,必须登录到注册期间使用的订阅,并使用 RegistrationNameResourceGroupName 参数的值,如管理员门户所示

# select the subscription used during the registration (shown in portal)
Select-AzSubscription -Subscription '<Registration subscription ID from portal>'
$YourPrivilegedEndpoint = "<privileged_endpoint_computer_name>"
# unregister using the parameter values from portal
Remove-AzsRegistration -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint -RegistrationName '<Registration name from portal>' -ResourceGroupName '<Registration resource group from portal>'
# switch to new subscription id
Select-AzSubscription -Subscription '<New subscription ID>'
# register
Set-AzsRegistration -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint -BillingModel '<Billing model>' -RegistrationName '<Registration name>' -ResourceGroupName '<Registration resource group name>'

更改计费模型、功能提供方式或重新注册实例

如果要更改计费模型、功能提供方式或要重新注册实例,可参考本部分。 对于上述所有情况,可以调用注册函数来设置新值。 不需要先删除当前注册。 登录管理员门户网站中显示的订阅 ID,然后使用新的 BillingModel 值重新运行注册,同时使 RegistrationNameResourceGroupName 参数值始终相同,如管理员门户所示:

# select the subscription used during the registration
Select-AzSubscription -Subscription '<Registration subscription ID from portal>'
$YourPrivilegedEndpoint = "<privileged_endpoint_computer_name>"
# rerun registration with new BillingModel (or same billing model in case of re-registration) but using other parameters values from portal
Set-AzsRegistration -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint -BillingModel '<New billing model>' -RegistrationName '<Registration name from portal>' -ResourceGroupName '<Registration resource group from portal>'

在以下情况下,需要更新或续订注册:

  • 续订基于容量的年度订阅之后。
  • 更改计费模式时。
  • 调整基于容量的计费(添加/删除节点)时。

从 Azure Stack Hub 中删除激活资源

首先需要从 Azure Stack Hub 中删除激活资源,然后再删除 Azure 中的注册资源。

若要删除 Azure Stack Hub 中的激活资源,请在 Azure Stack Hub 环境中运行以下 PowerShell cmdlet:

$YourPrivilegedEndpoint = "<privileged_endpoint_computer_name>"
Remove-AzsActivationResource -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint

接下来,若要删除 Azure 中的注册资源,请确保计算机已连接到 Azure,登录到正确的 Azure PowerShell 上下文,并运行相应的 PowerShell cmdlet,如下所示。

可以使用用于创建资源的注册令牌:

$RegistrationToken = "<registration token>"
Unregister-AzsEnvironment -RegistrationToken $RegistrationToken

或者,可以使用管理员门户上的注册名称和注册资源组名称:

Unregister-AzsEnvironment -RegistrationName '<Registration name from portal>' -ResourceGroupName '<Registration resource group from portal>'

使用连接的模型步骤重新注册

如果将计费模型从断开连接状态下的容量计费更改为连接状态下的使用计费,请按照连接的模型步骤重新注册。

注意

这不会更改你的标识模型,只会更改计费机制,你仍将使用 AD FS 作为标识源。

使用适用于联网场景的步骤重新注册

现已在离线场景中完全取消注册,接下来必须重复上述步骤,在离线场景中注册 Azure Stack Hub 环境。

禁用或启用使用情况报告

对于使用容量计费模型的 Azure Stack Hub 环境,请将 UsageReportingEnabled 参数与 Set-AzsRegistrationGet-AzsRegistrationToken cmdlet 配合使用,以便关闭使用情况报告功能。 默认情况下,Azure Stack Hub 报告使用情况指标。 使用容量或支持断开连接的环境的操作员需关闭使用情况报告功能。

运行以下 PowerShell cmdlet:

$CloudAdminCred = Get-Credential -UserName <Privileged endpoint credentials> -Message "Enter the cloud domain credentials to access the privileged endpoint."
$RegistrationName = "<unique-registration-name>"
Set-AzsRegistration `
   -PrivilegedEndpointCredential $CloudAdminCred `
   -PrivilegedEndpoint <PrivilegedEndPoint computer name> `
   -BillingModel Capacity
   -RegistrationName $RegistrationName
   -UsageReportingEnabled:$false
  1. 若要更改注册令牌,请运行以下 PowerShell cmdlet:

    $YourPrivilegedEndpoint = "<privileged_endpoint_computer_name>"
    $FilePathForRegistrationToken = $env:SystemDrive\RegistrationToken.txt
    $RegistrationToken = Get-AzsRegistrationToken -PrivilegedEndpointCredential $YourCloudAdminCredential -UsageReportingEnabled:$false -PrivilegedEndpoint $YourPrivilegedEndpoint -BillingModel Capacity -AgreementNumber '<EA agreement number>' -TokenOutputFilePath $FilePathForRegistrationToken
    

    使用购买容量 SKU 许可证的 EA 协议编号。

    提示

    注册令牌保存在为 $FilePathForRegistrationToken 指定的文件中。 可以自行更改文件路径或文件名。

  2. 保存此注册令牌,以便在连接 Azure 的计算机上使用。 可以从 $FilePathForRegistrationToken 复制文件或文本。

移动注册资源

对于所有环境,都支持在同一订阅下的资源组之间移动注册资源。 但是,只有当两个订阅都解析到同一个合作伙伴 ID 时,才支持在订阅之间移动注册资源。 有关将资源移到新的资源组的详细信息,请参阅将资源移到新的资源组或订阅

重要

为了防止意外删除门户上的注册资源,注册脚本会自动向资源添加一个锁。 在移动或删除该资源之前,必须先删除此锁。 建议你向注册资源添加锁,以防止意外删除。

注册参考

Set-AzsRegistration

可以使用 Set-AzsRegistration 将 Azure Stack Hub 注册到 Azure,并启用或禁用在市场中提供商品的功能和使用情况报告功能。

若要运行此 cmdlet,需具备:

  • 任何类型的全球 Azure 订阅。
  • 使用其身份为该订阅的所有者或参与者的帐户登录到 Azure PowerShell。
Set-AzsRegistration [-PrivilegedEndpointCredential] <PSCredential> [-PrivilegedEndpoint] <String> [[-AzureContext]
    <PSObject>] [[-ResourceGroupName] <String>] [[-ResourceGroupLocation] <String>] [[-BillingModel] <String>]
    [-MarketplaceSyndicationEnabled] [-UsageReportingEnabled] [[-AgreementNumber] <String>] [[-RegistrationName]
    <String>] [<CommonParameters>]
参数 类型 说明
PrivilegedEndpointCredential PSCredential 用于访问特权终结点的凭据。 用户名采用 AzureStackDomain\CloudAdmin 格式。
PrivilegedEndpoint String 预先配置的远程 PowerShell 控制台,提供的功能包括日志收集和其他部署后任务。 有关详细信息,请参阅使用特权终结点一文。
AzureContext PSObject
ResourceGroupName String
ResourceGroupLocation String
BillingModel String 订阅使用的计费模型。 此参数允许的值为:Capacity、PayAsYouUse 和 Development。
MarketplaceSyndicationEnabled True/False 确定市场管理功能在门户中是否可用。 如果通过 Internet 连接进行注册,请设置为 true。 如果在断开连接的环境中进行注册,请设置为 false。 对于断开连接的注册,可以使用脱机联合工具下载市场项。
UsageReportingEnabled True/False 默认情况下,Azure Stack Hub 报告使用情况指标。 使用容量或支持断开连接的环境的操作员需关闭使用情况报告功能。 此参数允许的值为:True、False。
AgreementNumber String 为此 Azure Stack 订购容量 SKU 所依据的 EA 协议编号。
RegistrationName String 如果在多个使用同一 Azure 订阅 ID 的 Azure Stack Hub 实例上运行注册脚本,请为注册设置唯一名称。 参数的默认值为 AzureStackRegistration。 但是,如果在多个 Azure Stack Hub 实例上使用同一名称,该脚本将会失败。

Get-AzsRegistrationToken

Get-AzsRegistrationToken 根据输入参数生成注册令牌。

Get-AzsRegistrationToken [-PrivilegedEndpointCredential] <PSCredential> [-PrivilegedEndpoint] <String>
    [-BillingModel] <String> [[-TokenOutputFilePath] <String>] [-UsageReportingEnabled] [[-AgreementNumber] <String>]
    [<CommonParameters>]
参数 类型 说明
PrivilegedEndpointCredential PSCredential 用于访问特权终结点的凭据。 用户名采用 AzureStackDomain\CloudAdmin 格式。
PrivilegedEndpoint String 预先配置的远程 PowerShell 控制台,提供的功能包括日志收集和其他部署后任务。 有关详细信息,请参阅使用特权终结点一文。
AzureContext PSObject
ResourceGroupName String
ResourceGroupLocation String
BillingModel String 订阅使用的计费模型。 此参数允许的值为:、和。
MarketplaceSyndicationEnabled True/False
UsageReportingEnabled True/False 默认情况下,Azure Stack Hub 报告使用情况指标。 使用容量或支持断开连接的环境的操作员需关闭使用情况报告功能。 此参数允许的值为:True、False。
AgreementNumber String

注册失败

在尝试注册 Azure Stack Hub 时,可能会看到以下错误之一:

  • 无法检索 $hostName 的必需硬件信息。 请检查物理主机和连接性,然后尝试重新运行注册。

  • 无法连接到 $hostName 以获取硬件信息。 请检查物理主机和连接性,然后尝试重新运行注册。

    原因:我们尝试从主机获取硬件详细信息(例如 UUID、Bios 和 CPU)以尝试激活,但却无法完成它,因为无法连接到物理主机。

  • 已注册云标识符 [GUID]。 不允许重复使用云标识符。

    原因:如果 Azure Stack 环境已注册,则会发生这种情况。 若要使用不同的订阅或计费模型重新注册环境,请按照续订或更改注册步骤进行操作。

  • 尝试访问市场管理时,会在尝试同步发布产品时出错。

    原因:当 Azure Stack Hub 无法访问注册资源时,通常会发生这种情况。 这种情况的一种常见原因是,当 Azure 订阅的目录租户更改时,它会重置注册。 如果已更改订阅的目录租户,将无法访问 Azure Stack Hub 市场或报告使用情况。 需要重新注册才能解决此问题。

  • 在你已经通过离线过程注册印花的情况下,市场管理仍会要求你注册并激活 Azure Stack Hub。

    原因:这是断开连接的环境的一个已知问题,需要你验证你的注册状态。 若要使用市场管理,请使用脱机工具

后续步骤

从 Azure 下载市场项