将 Azure Stack Hub 注册到 AzureRegister Azure Stack Hub with Azure

将 Azure Stack Hub 注册到 Azure,以便可以从 Azure 下载市场项,并设置向 Azure 报告商业数据的功能。Register Azure Stack Hub with Azure so you can download Azure Marketplace items from Azure and set up commerce data reporting back to Azure. 注册 Azure Stack Hub 之后,使用情况会报告给 Azure 商业组件,然后你就可以在用于注册的 Azure 计费订阅 ID 下查看它。After you register Azure Stack Hub, usage is reported to Azure commerce and you can see it under the Azure billing Subscription ID used for registration.

本文中的信息介绍如何向 Azure 注册 Azure Stack Hub 集成系统。The information in this article describes registering Azure Stack Hub integrated systems with Azure. 有关向 Azure 注册 ASDK 的信息,请参阅 ASDK 文档中的 Azure Stack Hub 注册For information about registering the ASDK with Azure, see Azure Stack Hub registration in the ASDK documentation.

重要

需要注册才能支持完整的 Azure Stack Hub 功能,包括在市场中提供商品。Registration is required to support full Azure Stack Hub functionality, including offering items in the marketplace. 如果在使用预付计费模式时不注册,将违反 Azure Stack Hub 许可条款。You'll be in violation of Azure Stack Hub licensing terms if you don't register when using the pay-in-advance billing model.

先决条件Prerequisites

在注册之前,请完成以下先决条件:Complete the following prerequisites before you register:

  • 验证凭据。Verify your credentials.
  • 设置 PowerShell 语言模式。Set the PowerShell language mode.
  • 安装适用于 Azure Stack Hub 的 PowerShell。Install PowerShell for Azure Stack Hub.
  • 下载 Azure Stack Hub 工具。Download the Azure Stack Hub tools.
  • 确定唯一注册名称。Determine your unique registration name.

验证凭据Verify your credentials

将 Azure Stack Hub 注册到 Azure 之前,必须准备好:Before registering Azure Stack Hub with Azure, you must have:

  • Azure 订阅的订阅 ID。The subscription ID for an Azure subscription. 注册仅支持 EA、CSP 或 CSP 共享服务订阅。Only EA, CSP, or CSP shared services subscriptions are supported for registration. CSP 需要确定是使用 CSP 订阅还是使用 APSS 订阅CSPs need to decide whether to use a CSP or APSS subscription.

    若要获取该 ID,请登录到 Azure,单击“所有服务”****。To get the ID, sign in to Azure, click All services. 然后,在“常规”**** 类别下,选择“订阅”,单击要使用的订阅,然后可以在“概要”下找到订阅 ID。**** ****Then, under the GENERAL category, select Subscriptions, click the subscription you want to use, and under Essentials you can find the Subscription ID. 最佳做法是,对生产环境和开发环境或测试环境使用单独的订阅。As a best practice, use separate subscriptions for production and dev or test environments.

  • 订阅所有者的帐户用户名和密码。The username and password for an account that's an owner for the subscription.

  • 用户帐户必须有权访问 Azure 订阅并且有权在与该订阅关联的目录中创建标识应用和服务主体。The user account needs to have access to the Azure subscription and have permissions to create identity apps and service principals in the directory associated with that subscription. 建议使用最低特权管理将 Azure Stack Hub 注册到 Azure。We recommend that you register Azure Stack Hub with Azure using least-privilege administration. 若要详细了解如何创建自定义角色定义,以便限制进行注册时对订阅的访问,请参阅为 Azure Stack Hub 创建注册角色For more information on how to create a custom role definition that limits access to your subscription for registration, see create a registration role for Azure Stack Hub.

  • 已注册 Azure Stack Hub 资源提供程序(请参阅下面的“注册 Azure Stack Hub 资源提供程序”部分了解详细信息)。Registered the Azure Stack Hub resource provider (see the following Register Azure Stack Hub Resource Provider section for details).

注册后,不需要 Azure Active Directory (Azure AD) 全局管理员权限。After registration, Azure Active Directory (Azure AD) global administrator permission isn't required. 但是,某些操作可能需要全局管理员凭据(例如,资源提供程序安装程序脚本或需要授予权限的新功能)。However, some operations may require the global admin credential (for example, 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.

注册 Azure Stack Hub 的用户是 Azure AD 中服务主体的所有者。The user who registers Azure Stack Hub is the owner of the service principal in Azure AD. 只有注册了 Azure Stack Hub 的用户可以修改 Azure Stack Hub 注册。Only the user who registered Azure Stack Hub can modify the Azure Stack Hub registration. 如果某位非管理员用户不是注册服务主体的所有者,则该用户在尝试注册或重新注册 Azure Stack Hub 时,可能会遇到 403 响应。If a non-admin user that's not an owner of the registration service principal attempts to register or re-register Azure Stack Hub, they may come across a 403 response. 403 响应表明用户权限不足,无法完成此操作。A 403 response indicates the user has insufficient permissions to complete the operation.

如果没有符合这些要求的 Azure 订阅,可以在此处创建一个试用版 Azure 帐户If you don't have an Azure subscription that meets these requirements, you can create a trial Azure account here. 注册 Azure Stack Hub 不会对 Azure 订阅收取任何费用。Registering Azure Stack Hub incurs no cost on your Azure subscription.

备注

如果有多个 Azure Stack Hub,最佳做法是将每个 Azure Stack Hub 注册到其自己的订阅。If you have more than one Azure Stack Hub, a best practice is to register each Azure Stack Hub to its own subscription. 这样可以更容易地跟踪使用情况。This makes it easier for you to track usage.

设置 PowerShell 语言模式Set the PowerShell language mode

若要成功注册 Azure Stack Hub,必须将 PowerShell 语言模式设置为 FullLanguageModeTo successfully register Azure Stack Hub, the PowerShell language mode must be set to FullLanguageMode. 若要验证当前的语言模式是否设置为 Full,请打开权限提升的 PowerShell 窗口,并运行以下 PowerShell cmdlet:To verify that the current language mode is set to full, open an elevated PowerShell window and run the following PowerShell cmdlets:

$ExecutionContext.SessionState.LanguageMode

确保输出返回的是 FullLanguageModeEnsure the output returns FullLanguageMode. 如果返回了其他任何语言模式,则需要在另一台计算机上运行注册,或者将语言模式设置为 FullLanguageMode,然后才能继续。If any other language mode is returned, registration needs to be run on another machine or the language mode needs to be set to FullLanguageMode before continuing.

安装适用于 Azure Stack Hub 的 PowerShellInstall PowerShell for Azure Stack Hub

使用适用于 Azure Stack Hub 的最新 PowerShell 来注册到 Azure。Use the latest PowerShell for Azure Stack Hub to register with Azure.

如果最新版本尚未安装,请参阅安装适用于 Azure Stack Hub 的 PowerShellIf the latest version isn't already installed, see install PowerShell for Azure Stack Hub.

下载 Azure Stack Hub 工具Download the Azure Stack Hub tools

Azure Stack Hub 工具 GitHub 存储库包含支持 Azure Stack Hub 功能(包括注册功能)的 PowerShell 模块。The Azure Stack Hub tools GitHub repository contains PowerShell modules that support Azure Stack Hub functionality, including registration functionality. 在注册过程中,需要导入并使用 Azure Stack Hub 工具存储库中的 RegisterWithAzure.psm1 PowerShell 模块,将 Azure Stack Hub 实例注册到 Azure。During the registration process, you need to import and use the RegisterWithAzure.psm1 PowerShell module (found in the Azure Stack Hub tools repository) to register your Azure Stack Hub instance with Azure.

若要确保使用最新版本,请在注册到 Azure 之前删除 Azure Stack Hub 工具的任何现有版本,然后从 GitHub 下载最新版本To ensure you're using the latest version, delete any existing versions of the Azure Stack Hub tools and download the latest version from GitHub before registering with Azure.

确定计费模型Determine your billing model

连接的部署允许 Azure Stack Hub 连接到 Internet 和 Azure。A connected deployment allows Azure Stack Hub to connect to the internet, and to Azure. 你也可以使用 Azure AD 或 Active Directory 联合身份验证服务 (AD FS) 作为标识存储,并从两种计费模型中进行选择:“即用即付”或“基于容量”。You can also use either Azure AD or Active Directory Federation Services (AD FS) as your identity store, and choose from two billing models: pay-as-you-use or capacity-based. 稍后在运行注册脚本时指定计费模型。You specify the billing model later, while running the registration script.

确定唯一注册名称Determine your unique registration name

运行注册脚本时,必须提供唯一的注册名称。When you run the registration script, you must provide a unique registration name. 将 Azure Stack Hub 订阅与 Azure 注册关联的简便方法是使用 Azure Stack Hub 云 IDAn easy way to associate your Azure Stack Hub subscription with an Azure registration is to use your Azure Stack Hub Cloud ID.

备注

使用基于容量的计费模型的 Azure Stack Hub 注册将需要在这些年度订阅到期后重新注册时更改唯一名称,除非你删除过期的注册并重新注册到 Azure。Azure Stack Hub registrations using the capacity-based billing model will need to change the unique name when re-registering after those yearly subscriptions expire unless you delete the expired registration and re-register with Azure.

若要确定 Azure Stack Hub 部署的云 ID,请参阅查找云 IDTo determine the Cloud ID for your Azure Stack Hub deployment, see Find your cloud ID.

使用预先支付计费模型注册Register with pay-in-advance billing

执行以下步骤,使用预先支付计费模型将 Azure Stack Hub 注册到 Azure。Use these steps to register Azure Stack Hub with Azure using the pay-in-advance billing model.

备注

所有这些步骤必须在可以访问特权终结点 (PEP) 的计算机上运行。All these steps must be run from a computer that has access to the privileged endpoint (PEP). 有关 PEP 的详细信息,请参阅使用 Azure Stack Hub 中的特权终结点For details about the PEP, see Using the privileged endpoint in Azure Stack Hub.

连接的环境可以访问 Internet 和 Azure。Connected environments can access the internet and Azure. 对于这些环境,需将 Azure Stack Hub 资源提供程序注册到 Azure,然后配置计费模式。For these environments, you need to register the Azure Stack Hub resource provider with Azure and then configure your billing model.

  1. 若要向 Azure 注册 Azure Stack Hub 资源提供程序,请以管理员身份启动 PowerShell ISE,然后使用以下 PowerShell cmdlet,并将 EnvironmentName 参数设置为相应的 Azure 订阅类型(请参阅下面的“参数”)。To register the Azure Stack Hub resource provider with Azure, start PowerShell ISE as an administrator and use the following PowerShell cmdlets with the EnvironmentName parameter set to the appropriate Azure subscription type (see parameters below).

  2. 添加用于注册 Azure Stack Hub 的 Azure 帐户。Add the Azure account that you used to register Azure Stack Hub. 若要添加该帐户,请运行 Add-AzureRmAccount cmdlet。To add the account, run the Add-AzureRmAccount cmdlet. 系统会提示输入 Azure 帐户凭据。根据帐户的配置,可能需要使用双因素身份验证。You're prompted to enter your Azure account credentials and you may have to use two-factor authentication based on your account's configuration.

    Add-AzureRmAccount -EnvironmentName "<environment name>"
    
    参数Parameter 说明Description
    EnvironmentNameEnvironmentName Azure 云订阅环境名称。The Azure cloud subscription environment name. 受支持的环境名称是 AzureChinaCloudSupported environment name is AzureChinaCloud.

    备注

    如果会话过期,密码已更改,或者只是希望切换帐户,请在使用 Add-AzureRmAccount 登录之前运行以下 cmdlet:Remove-AzureRmAccount-Scope ProcessIf your session expires, your password has changed, or you simply wish to switch accounts, run the following cmdlet before you sign in using Add-AzureRmAccount: Remove-AzureRmAccount-Scope Process

  3. 如果有多个订阅,请运行以下命令,选择要使用的那个订阅:If you have multiple subscriptions, run the following command to select the one you want to use:

    Get-AzureRmSubscription -SubscriptionID '<Your Azure Subscription GUID>' | Select-AzureRmSubscription
    
  4. 运行以下命令,在 Azure 订阅中注册 Azure Stack Hub 资源提供程序:Run the following command to register the Azure Stack Hub resource provider in your Azure subscription:

    Register-AzureRmResourceProvider -ProviderNamespace Microsoft.AzureStack
    
  5. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-master 目录中的 Registration 文件夹。Start PowerShell ISE as an administrator and navigate to the Registration folder in the AzureStack-Tools-master directory created when you downloaded the Azure Stack Hub tools. 使用 PowerShell 导入 RegisterWithAzure.psm1 模块:Import the RegisterWithAzure.psm1 module using PowerShell:

    Import-Module .\RegisterWithAzure.psm1
    
  6. 接下来,在同一个 PowerShell 会话中,确保已登录到正确的 Azure PowerShell 上下文。Next, in the same PowerShell session, ensure you're signed in to the correct Azure PowerShell context. 此上下文是前面在注册 Azure Stack Hub 资源提供程序时所用的 Azure 帐户。This context would be the Azure account that was used to register the Azure Stack Hub resource provider previously. 要运行的 PowerShell:PowerShell to run:

    Connect-AzureRmAccount -Environment "<environment name>"
    
    参数Parameter 说明Description
    EnvironmentNameEnvironmentName Azure 云订阅环境名称。The Azure cloud subscription environment name. 受支持的环境名称是 AzureChinaCloudSupported environment name is AzureChinaCloud.
  7. 在同一个 PowerShell 会话中运行 Set-AzsRegistration cmdlet。In the same PowerShell session, run the Set-AzsRegistration cmdlet. 要运行的 PowerShell:PowerShell to run:

    $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 PayInAdvance `
       -RegistrationName $RegistrationName
    

    有关 Set-AzsRegistration cmdlet 的详细信息,请参阅注册参考For more information on the Set-AzsRegistration cmdlet, see Registration reference.

    该过程需要花费 10 到 15 分钟。The process takes between 10 and 15 minutes. 命令完成后,会显示以下消息:“现已使用提供的参数注册并激活环境”。****When the command completes, you see the message "Your environment is now registered and activated using the provided parameters."

使用容量计费模型注册Register with capacity billing

执行以下步骤,使用容量计费模型将 Azure Stack Hub 注册到 Azure。Use these steps to register Azure Stack Hub with Azure using the capacity billing model.

备注

所有这些步骤必须在可以访问特权终结点 (PEP) 的计算机上运行。All these steps must be run from a computer that has access to the privileged endpoint (PEP). 有关 PEP 的详细信息,请参阅使用 Azure Stack Hub 中的特权终结点For details about the PEP, see Using the privileged endpoint in Azure Stack Hub.

连接的环境可以访问 Internet 和 Azure。Connected environments can access the internet and Azure. 对于这些环境,需将 Azure Stack Hub 资源提供程序注册到 Azure,然后配置计费模式。For these environments, you need to register the Azure Stack Hub resource provider with Azure and then configure your billing model.

  1. 若要向 Azure 注册 Azure Stack Hub 资源提供程序,请以管理员身份启动 PowerShell ISE,然后使用以下 PowerShell cmdlet,并将 EnvironmentName 参数设置为相应的 Azure 订阅类型(请参阅下面的“参数”)。To register the Azure Stack Hub resource provider with Azure, start PowerShell ISE as an administrator and use the following PowerShell cmdlets with the EnvironmentName parameter set to the appropriate Azure subscription type (see parameters below).

  2. 添加用于注册 Azure Stack Hub 的 Azure 帐户。Add the Azure account that you used to register Azure Stack Hub. 若要添加该帐户,请运行 Add-AzureRmAccount cmdlet。To add the account, run the Add-AzureRmAccount cmdlet. 系统会提示输入 Azure 帐户凭据。根据帐户的配置,可能需要使用双因素身份验证。You're prompted to enter your Azure account credentials and you may have to use two-factor authentication based on your account's configuration.

    Connect-AzureRmAccount -Environment "<environment name>"
    
    参数Parameter 说明Description
    EnvironmentNameEnvironmentName Azure 云订阅环境名称。The Azure cloud subscription environment name. 受支持的环境名称是 AzureChinaCloudSupported environment name is AzureChinaCloud.
  3. 如果有多个订阅,请运行以下命令,选择要使用的那个订阅:If you have multiple subscriptions, run the following command to select the one you want to use:

    Get-AzureRmSubscription -SubscriptionID '<Your Azure Subscription GUID>' | Select-AzureRmSubscription
    
  4. 运行以下命令,在 Azure 订阅中注册 Azure Stack Hub 资源提供程序:Run the following command to register the Azure Stack Hub resource provider in your Azure subscription:

    Register-AzureRmResourceProvider -ProviderNamespace Microsoft.AzureStack
    
  5. 以管理员身份启动 PowerShell ISE,并导航到下载 Azure Stack Hub 工具时所创建的 AzureStack-Tools-master 目录中的 Registration 文件夹。Start PowerShell ISE as an administrator and navigate to the Registration folder in the AzureStack-Tools-master directory created when you downloaded the Azure Stack Hub tools. 使用 PowerShell 导入 RegisterWithAzure.psm1 模块:Import the RegisterWithAzure.psm1 module using PowerShell:

    $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
    

    备注

    可以通过将参数设置为 false 来使用 Set-AzsRegistration cmdlet 的 UsageReportingEnabled 参数禁用使用情况报告。You can disable usage reporting with the UsageReportingEnabled parameter for the Set-AzsRegistration cmdlet by setting the parameter to false.

    有关 Set-AzsRegistration cmdlet 的详细信息,请参阅注册参考For more information on the Set-AzsRegistration cmdlet, see Registration reference.

验证 Azure Stack Hub 注册Verify Azure Stack Hub registration

可以使用“区域管理”磁贴验证 Azure Stack Hub 注册是否成功。****You can use the Region management tile to verify that the Azure Stack Hub registration was successful. 可在管理员门户的默认仪表板上使用此磁贴。This tile is available on the default dashboard in the administrator portal. 状态可能是已注册,也可能是未注册。The status can be registered, or not registered. 如果是已注册,则还会显示用于注册 Azure Stack Hub 的 Azure 订阅 ID,以及注册资源组和名称。If registered, it also shows the Azure subscription ID that you used to register your Azure Stack Hub along with the registration resource group and name.

  1. 登录到 Azure Stack Hub 管理员门户 https://adminportal.local.azurestack.externalSign in to the Azure Stack Hub administrator portal https://adminportal.local.azurestack.external.

  2. 在“仪表板”中,选择“区域管理”。****From the Dashboard, select Region management.

  3. 选择“属性”。Select Properties. 此边栏选项卡显示环境的状态和详细信息。This blade shows the status and details of your environment. 状态可能是“已注册”、“未注册”或“已过期”。**** **** ****The status can be Registered, Not registered, or Expired.

    Azure Stack Hub 管理员门户中的“区域管理”磁贴Region management tile in Azure Stack Hub administrator portal

    如果已注册,则属性包括:If registered, the properties include:

    • 注册订阅 ID:已注册并与 Azure Stack Hub 关联的 Azure 订阅 ID。Registration subscription ID: The Azure subscription ID registered and associated to Azure Stack Hub.
    • 注册资源组:包含 Azure Stack Hub 资源的关联订阅中的 Azure 资源组。Registration resource group: The Azure resource group in the associated subscription containing the Azure Stack Hub resources.
  4. 可以使用 Azure 门户查看 Azure Stack Hub 注册资源,然后验证注册是否成功。You can use the Azure portal to view Azure Stack Hub registration resources, and then verify that the registration succeeded. 使用已关联到用于注册 Azure Stack Hub 的订阅的帐户登录到 Azure 门户Sign in to the Azure portal using an account associated to the subscription you used to register Azure Stack Hub. 选择“所有资源”****,启用“显示隐藏类型”**** 复选框,然后选择注册名称。Select All resources, enable the Show hidden types checkbox, and select the registration name.

  5. 如果注册未成功,则必须按照此处的步骤重新注册以解决问题。If the registration didn't succeed, you must re-register by following the steps here to resolve the issue.

或者,可以使用“市场管理”功能来验证注册是否成功。Alternatively, you can verify if your registration was successful by using the Marketplace management feature. 如果在“市场管理”边栏选项卡中看到市场项列表,即表示注册成功。If you see a list of marketplace items in the Marketplace management blade, your registration was successful. 但是,在离线环境中,无法在“市场管理”中看到市场项。However, in disconnected environments, you can't see marketplace items in Marketplace management.

备注

完成注册后,将不再显示提示未注册的活动警告。After registration is complete, the active warning for not registering will no longer appear. 对于早于 1904 的 Azure Stack Hub 版本,在离线场景中,即使已注册成功,“市场管理”中也仍会显示一条消息,要求你注册并激活 Azure Stack Hub。In Azure Stack Hub releases before 1904, in disconnected scenarios, you see a message in Marketplace management asking you to register and activate your Azure Stack Hub, even if you have registered successfully. 此消息不会出现在 1904 版和更高版本中。This message doesn't appear in release 1904 and later.

续订或更改注册Renew or change registration

在以下情况下,需要更新或续订注册:You need to update or renew your registration in the following circumstances:

  • 续订基于容量的年度订阅之后。After you renew your capacity-based yearly subscription.
  • 更改计费模式时。When you change your billing model.
  • 调整基于容量的计费(添加/删除节点)时。When you scale changes (add/remove nodes) for capacity-based billing.

先决条件Prerequisites

若要续订或更改注册,需要管理员门户中的以下信息:You need the following information from the administrator portal to renew or change registration:

管理员门户Administrator portal Cmdlet 参数Cmdlet parameter 注释Notes
注册订阅 IDREGISTRATION SUBSCRIPTION ID 订阅Subscription 上一次注册期间使用的订阅 IDSubscription ID used during previous registration
注册资源组REGISTRATION RESOURCE GROUP ResourceGroupNameResourceGroupName 以前的注册资源所在的资源组Resource group under which the previous registration resource exists
注册名称REGISTRATION NAME RegistrationNameRegistrationName 上一次注册期间使用的注册名称Registration name used during previous registration

更改使用的订阅Change the subscription you use

若要更改使用的订阅,必须先运行 Remove-AzsRegistration cmdlet,并确保登录到正确的 Azure PowerShell 上下文。If you want to change the subscription you use, you must first run the Remove-AzsRegistration cmdlet, then ensure you're signed in to the correct Azure PowerShell context. 然后使用任何已更改的参数(包括 <billing model>)运行 Set-AzsRegistration****。Then run Set-AzsRegistration with any changed parameters, including <billing model>. 运行 Remove-AzsRegistration 时,必须登录到注册期间使用的订阅,并使用 RegistrationNameResourceGroupName 参数的值,如管理员门户所示****:While running Remove-AzsRegistration, you must be signed in to the subscription used during the registration and use values of the RegistrationName and ResourceGroupName parameters as shown in the administrator portal:

# select the subscription used during the registration (shown in portal)
Select-AzureRmSubscription -Subscription '<Registration subscription ID from portal>'
# 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-AzureRmSubscription -Subscription '<New subscription ID>'
# register 
Set-AzsRegistration -PrivilegedEndpointCredential $YourCloudAdminCredential -PrivilegedEndpoint $YourPrivilegedEndpoint -BillingModel '<Billing model>' -RegistrationName '<Registration name>' --ResourceGroupName '<Registration resource group name>'

更改计费模型、功能提供方式或重新注册实例Change billing model, how features are offered, or re-register your instance

如果要更改计费模型、功能提供方式或要重新注册实例,可参考本部分。This section applies if you want to change the billing model, how features are offered, or you want to re-register your instance. 对于上述所有情况,可以调用注册函数来设置新值。For all of these cases, you call the registration function to set the new values. 不需要先删除当前注册。You don't need to first remove the current registration. 登录管理员门户网站中显示的订阅 ID,然后使用新的 BillingModel 值重新运行注册,同时使 RegistrationNameResourceGroupName 参数值始终相同,如管理员门户所示:Sign in to the subscription ID shown in the administrator portal, and then rerun registration with a new BillingModel value while keeping the RegistrationName and ResourceGroupName parameters values same as shown in the administrator portal:

# select the subscription used during the registration
Select-AzureRmSubscription -Subscription '<Registration subscription ID from portal>'
# 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>'

禁用或启用使用情况报告Disable or enable usage reporting

对于使用容量计费模型的 Azure Stack Hub 环境,请将 UsageReportingEnabled 参数与 Set-AzsRegistrationGet-AzsRegistrationToken cmdlet 配合使用,以便关闭使用情况报告功能。For Azure Stack Hub environments that use a capacity billing model, turn off usage reporting with the UsageReportingEnabled parameter using either the Set-AzsRegistration or the Get-AzsRegistrationToken cmdlets. 默认情况下,Azure Stack Hub 报告使用情况指标。Azure Stack Hub reports usage metrics by default. 使用容量或支持断开连接的环境的操作员需关闭使用情况报告功能。Operators with capacity uses or supporting a disconnected environment need to turn off usage reporting.

运行以下 PowerShell cmdlet:Run the following PowerShell cmdlets:

$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

移动注册资源Move a registration resource

对于所有环境,都支持在同一订阅下的资源组之间移动注册资源****。Moving a registration resource between resource groups under the same subscription is supported for all environments. 但是,只有当两个订阅都解析到同一个合作伙伴 ID 时,才支持在订阅之间移动注册资源。However, moving a registration resource between subscriptions is only supported for CSPs when both subscriptions resolve to the same Partner ID. 有关将资源移到新的资源组的详细信息,请参阅将资源移到新的资源组或订阅For more information about moving resources to a new resource group, see Move resources to new resource group or subscription.

重要

为了防止意外删除门户上的注册资源,注册脚本会自动向资源添加一个锁。To prevent accidental deletion of registration resources on the portal, the registration script automatically adds a lock to the resource. 在移动或删除该资源之前,必须先删除此锁。You must remove this lock before moving or deleting it. 建议你向注册资源添加锁,以防止意外删除。It's recommended that you add a lock to your registration resource to prevent accidental deletion.

注册参考Registration reference

Set-AzsRegistrationSet-AzsRegistration

可以使用 Set-AzsRegistration 将 Azure Stack Hub 注册到 Azure,并启用或禁用在市场中提供商品的功能和使用情况报告功能。You can use Set-AzsRegistration to register Azure Stack Hub with Azure and enable or disable the offer of items in the marketplace and usage reporting.

若要运行此 cmdlet,需具备:To run the cmdlet, you need:

  • 任何类型的全球 Azure 订阅。A global Azure subscription of any type.
  • 使用其身份为该订阅的所有者或参与者的帐户登录到 Azure PowerShell。To be signed in to Azure PowerShell with an account that's an owner or contributor to that subscription.
Set-AzsRegistration [-PrivilegedEndpointCredential] <PSCredential> [-PrivilegedEndpoint] <String> [[-AzureContext]
    <PSObject>] [[-ResourceGroupName] <String>] [[-ResourceGroupLocation] <String>] [[-BillingModel] <String>]
    [-MarketplaceSyndicationEnabled] [[-AgreementNumber] <String>] [[-RegistrationName]
    <String>] [<CommonParameters>]
参数Parameter 类型Type 说明Description
PrivilegedEndpointCredentialPrivilegedEndpointCredential PSCredentialPSCredential 用于访问特权终结点的凭据。The credentials used to access the privileged endpoint. 用户名采用 AzureStackDomain\CloudAdmin 格式。The username is in the format AzureStackDomain\CloudAdmin.
PrivilegedEndpointPrivilegedEndpoint StringString 预先配置的远程 PowerShell 控制台,提供的功能包括日志收集和其他部署后任务。A pre-configured remote PowerShell console that provides you with capabilities like log collection and other post deployment tasks. 有关详细信息,请参阅使用特权终结点一文。To learn more, refer to the using the privileged endpoint article.
AzureContextAzureContext PSObjectPSObject
ResourceGroupNameResourceGroupName StringString
ResourceGroupLocationResourceGroupLocation StringString
BillingModelBillingModel StringString 订阅使用的计费模型。The billing model that your subscription uses. 此参数允许的值为:Capacity、PayAsYouUse 和 Development。Allowed values for this parameter are: Capacity, PayAsYouUse, and Development.
MarketplaceSyndicationEnabledMarketplaceSyndicationEnabled True/FalseTrue/False 确定市场管理功能在门户中是否可用。Determines if the marketplace management feature is available in the portal. 如果通过 Internet 连接进行注册,请设置为 true。Set to true if registering with internet connectivity. 如果在断开连接的环境中进行注册,请设置为 false。Set to false if registering in disconnected environments. 对于断开连接的注册,可以使用脱机联合工具下载市场项。For disconnected registrations, the offline syndication tool can be used for downloading marketplace items.
UsageReportingEnabledUsageReportingEnabled True/FalseTrue/False 默认情况下,Azure Stack Hub 报告使用情况指标。Azure Stack Hub reports usage metrics by default. 使用容量或支持断开连接的环境的操作员需关闭使用情况报告功能。Operators with capacity uses or supporting a disconnected environment need to turn off usage reporting. 此参数允许的值为:True、False。Allowed values for this parameter are: True, False.
AgreementNumberAgreementNumber StringString 为此 Azure Stack 订购容量 SKU 所依据的 EA 协议编号。The number of the EA agreement under which the Capacity SKU for this Azure Stack was ordered.
RegistrationNameRegistrationName StringString 如果在多个使用同一 Azure 订阅 ID 的 Azure Stack Hub 实例上运行注册脚本,请为注册设置唯一名称。Set a unique name for the registration if you're running the registration script on more than one instance of Azure Stack Hub using the same Azure Subscription ID. 参数的默认值为 AzureStackRegistrationThe parameter has a default value of AzureStackRegistration. 但是,如果在多个 Azure Stack Hub 实例上使用同一名称,该脚本将会失败。However, if you use the same name on more than one instance of Azure Stack Hub, the script fails.

Get-AzsRegistrationTokenGet-AzsRegistrationToken

Get-AzsRegistrationToken 根据输入参数生成注册令牌。Get-AzsRegistrationToken generates a registration token from the input parameters.

Get-AzsRegistrationToken [-PrivilegedEndpointCredential] <PSCredential> [-PrivilegedEndpoint] <String>
    [-BillingModel] <String> [[-TokenOutputFilePath] <String>] [[-AgreementNumber] <String>]
    [<CommonParameters>]
参数Parameter 类型Type 说明Description
PrivilegedEndpointCredentialPrivilegedEndpointCredential PSCredentialPSCredential 用于访问特权终结点的凭据。The credentials used to access the privileged endpoint. 用户名采用 AzureStackDomain\CloudAdmin 格式。The username is in the format AzureStackDomain\CloudAdmin.
PrivilegedEndpointPrivilegedEndpoint StringString 预先配置的远程 PowerShell 控制台,提供的功能包括日志收集和其他部署后任务。A pre-configured remote PowerShell console that provides you with capabilities like log collection and other post deployment tasks. 有关详细信息,请参阅使用特权终结点一文。To learn more, refer to the using the privileged endpoint article.
AzureContextAzureContext PSObjectPSObject
ResourceGroupNameResourceGroupName StringString
ResourceGroupLocationResourceGroupLocation StringString
BillingModelBillingModel StringString 订阅使用的计费模型。The billing model that your subscription uses. 此参数允许的值为:Capacity、PayAsYouUse 和 Development。Allowed values for this parameter are: Capacity, PayAsYouUse, and Development.
MarketplaceSyndicationEnabledMarketplaceSyndicationEnabled True/FalseTrue/False
UsageReportingEnabledUsageReportingEnabled True/FalseTrue/False 默认情况下,Azure Stack Hub 报告使用情况指标。Azure Stack Hub reports usage metrics by default. 使用容量或支持断开连接的环境的操作员需关闭使用情况报告功能。Operators with capacity uses or supporting a disconnected environment need to turn off usage reporting. 此参数允许的值为:True、False。Allowed values for this parameter are: True, False.
AgreementNumberAgreementNumber StringString

注册失败Registration failures

在尝试注册 Azure Stack Hub 时,可能会看到以下错误之一:You might see one of the errors below while attempting to register your Azure Stack Hub:

  • 无法检索 $hostName 的必需硬件信息。Could not retrieve mandatory hardware info for $hostName. 请检查物理主机和连接性,然后尝试重新运行注册。Check physical host and connectivity, then try to rerun registration.

  • 无法连接到 $hostName 以获取硬件信息。Cannot connect to $hostName to get hardware info. 请检查物理主机和连接性,然后尝试重新运行注册。Check physical host and connectivity, then try to rerun registration.

    原因:这通常是因为我们尝试从主机获取硬件详细信息(例如 UUID、Bios 和 CPU)以尝试激活,但却无法完成它,因为无法连接到物理主机。Cause: this is typically because we try to obtain hardware details such as UUID, Bios, and CPU from the hosts to attempt activation and weren't able to due to the inability to connect to the physical host.

  • 已注册云标识符 [GUID]。Cloud identifier [GUID] is already registered. 不允许重复使用云标识符。Reusing cloud identifiers is not allowed.

    原因:如果 Azure Stack 环境已注册,则会发生这种情况。Cause: this happens if your Azure Stack environment is already registered. 若要使用不同的订阅或计费模型重新注册环境,请按照续订或更改注册步骤进行操作。If you want to re-register your environment with a different subscription or billing model, follow the Renew or change registration steps.

  • 尝试访问市场管理时,会在尝试同步发布产品时出错。When trying to access Marketplace management, an error occurs when trying to syndicate products.

    原因:当 Azure Stack Hub 无法访问注册资源时,通常会发生这种情况。Cause: this usually happens when Azure Stack Hub is unable to access the registration resource. 这种情况的一种常见原因是,当 Azure 订阅的目录租户更改时,它会重置注册。One common reason for this is that when an Azure subscription's directory tenant changes, it resets the registration. 如果已更改订阅的目录租户,将无法访问 Azure Stack Hub 市场或报告使用情况。You can't access the Azure Stack Hub Marketplace or report usage if you've changed the subscription's directory tenant. 需要重新注册才能解决此问题。You need to re-register to fix this issue.

后续步骤Next steps

从 Azure 下载市场项Download marketplace items from Azure