在 Azure Stack Hub 中注册租户以跟踪使用情况Register tenants for usage tracking in Azure Stack Hub

本文包含有关注册操作的详细信息。This article contains details about registration operations. 可以使用这些操作:You can use these operations to:

  • 管理租户注册。Manage tenant registrations.
  • 管理租户使用情况跟踪。Manage tenant usage tracking.

将租户添加到注册Add tenant to registration

如果要在注册中添加新租户,可以使用此操作。You can use this operation when you want to add a new tenant to your registration. 在与 Azure Active Directory (Azure AD) 租户连接的 Azure 订阅下报告租户使用情况。Tenant usage is reported under an Azure subscription connected with the Azure Active Directory (Azure AD) tenant.

还可以使用此操作来更改与租户关联的订阅。You can also use this operation to change the subscription associated with a tenant. 调用 PUT 或 New-AzureRMResource PowerShell cmdlet 来覆盖以前的映射。Call PUT or the New-AzureRMResource PowerShell cmdlet to overwrite the previous mapping.

可以将单个 Azure 订阅与一个租户相关联。You can associate a single Azure subscription with a tenant. 如果尝试将第二个订阅添加到现有租户,则第一个订阅将被覆盖。If you try to add a second subscription to an existing tenant, the first subscription is overwritten.

使用 API 配置文件Use API profiles

以下注册 cmdlet 要求你在运行 PowerShell 时指定一个 API 配置文件。The following registration cmdlets require that you specify an API profile when running PowerShell. API 配置文件表示一组 Azure 资源提供程序及其 API 版本。API profiles represent a set of Azure resource providers and their API versions. 当与多个 Azure 云进行交互时,它们可帮助你使用 API 的正确版本。They help you use the right version of the API when interacting with multiple Azure clouds. 例如,如果你在使用全局 Azure 和 Azure Stack Hub 时使用多个云,则 API 配置文件指定一个与其发布日期相匹配的名称。For example, if you work with multiple clouds when working with global Azure and Azure Stack Hub, API profiles specify a name that matches their release date. 使用 2017-09-03 配置文件。You use the 2017-09-03 profile.

有关 Azure Stack Hub 和 API 配置文件的详细信息,请参阅在 Azure Stack Hub 中管理 API 版本配置文件For more information about Azure Stack Hub and API profiles, see Manage API version profiles in Azure Stack Hub.

parametersParameters

参数Parameter 说明Description
registrationSubscriptionIDregistrationSubscriptionID 用于初始注册的 Azure 订阅。The Azure subscription that was used for the initial registration.
customerSubscriptionIDcustomerSubscriptionID 属于要注册的客户的 Azure 订阅(非 Azure Stack Hub)。The Azure subscription (not Azure Stack Hub) belonging to the customer to be registered. 必须通过合作伙伴中心在云解决方案提供商 (CSP) 产品/服务中创建。Must be created in the Cloud Solution Provider (CSP) offer through the Partner Center. 如果客户有多个租户,则为要登录 Azure Stack Hub 的租户创建订阅。If a customer has more than one tenant, create a subscription for the tenant to sign in to Azure Stack Hub. 客户订阅 ID 区分大小写。The customer subscription ID is case sensitive.
resourceGroupresourceGroup Azure 中用于存储注册的资源组。The resource group in Azure in which your registration is stored.
registrationNameregistrationName Azure Stack Hub 的注册名称。The name of the registration of your Azure Stack Hub. 它是 Azure 中存储的对象。It's an object stored in Azure. 该名称通常采用格式 azurestack-CloudID,其中 CloudID 是 Azure Stack Hub 部署的云 ID。The name is usually in the form azurestack-CloudID, where CloudID is the cloud ID of your Azure Stack Hub deployment.

备注

租户必须注册到它们使用的每个 Azure Stack Hub 部署。Tenants must be registered with each Azure Stack Hub deployment that they use. 如果租户使用多个 Azure Stack Hub,则需要使用租户订阅更新每个部署的初始注册。If a tenant uses more than one Azure Stack Hub, update the initial registrations of each deployment with the tenant subscription.

PowerShellPowerShell

使用 New-AzureRmResource cmdlet 添加一个租户。Use the New-AzureRmResource cmdlet to add a tenant. 连接到 Azure,然后在提升的提示符下运行以下命令:Connect to Azure, and then from an elevated prompt run the following command:

New-AzureRmResource -ResourceId "subscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}" -ApiVersion 2017-06-01

API 调用API call

Operation:PUTOperation: PUT
RequestURIsubscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}?api-version=2017-06-01 HTTP/1.1RequestURI: subscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}?api-version=2017-06-01 HTTP/1.1
响应:201 CreatedResponse: 201 Created
响应正文:空Response Body: Empty

列出所有已注册租户List all registered tenants

获取已添加到注册的所有租户列表。Get a list of all tenants that have been added to a registration.

备注

如果没有租户已注册,则不会收到响应。If no tenants have been registered, you won't receive a response.

parametersParameters

参数Parameter 说明Description
registrationSubscriptionIdregistrationSubscriptionId 用于初始注册的 Azure 订阅。The Azure subscription that was used for the initial registration.
resourceGroupresourceGroup Azure 中用于存储注册的资源组。The resource group in Azure in which your registration is stored.
registrationNameregistrationName Azure Stack Hub 部署的注册名称。The name of the registration of your Azure Stack Hub deployment. 它是 Azure 中存储的对象。It's an object stored in Azure. 该名称通常采用格式 azurestack-CloudID,其中 CloudID 是 Azure Stack Hub 部署的云 ID。The name is usually in the form of azurestack-CloudID, where CloudID is the cloud ID of your Azure Stack Hub deployment.

PowerShellPowerShell

使用 Get-AzureRmResource cmdlet 列出所有已注册的租户。Use the Get-AzureRmResource cmdlet to list all registered tenants. 连接到 Azure Stack Hub,然后从提升的提示符运行以下 cmdlet:Connect to Azure Stack Hub, and then from an elevated prompt run the following cmdlet:

Get-AzureRmResource -ResourceId "subscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions" -ApiVersion 2017-06-01

API 调用API call

可以使用 GET 操作获取所有租户映射的列表。You can get a list of all tenant mappings using the GET operation.

Operation:GETOperation: GET
RequestURIsubscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions?api-version=2017-06-01 HTTP/1.1RequestURI: subscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions?api-version=2017-06-01 HTTP/1.1
响应:200Response: 200
响应正文Response Body:

{
    "value": [{
            "id": " subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{ cspSubscriptionId 1}",
            "name": " cspSubscriptionId 1",
            "type": "Microsoft.AzureStack\customerSubscriptions",
            "properties": { "tenantId": "tId1" }
        },
        {
            "id": " subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{ cspSubscriptionId 2}",
            "name": " cspSubscriptionId2 ",
            "type": "Microsoft.AzureStack\customerSubscriptions",
            "properties": { "tenantId": "tId2" }
        }
    ],
    "nextLink": "{originalRequestUrl}?$skipToken={opaqueString}"
}

删除租户映射Remove a tenant mapping

可以删除已添加到注册的租户。You can remove a tenant that has been added to a registration. 如果该租户仍在使用 Azure Stack Hub 上的资源,则会对初始 Azure Stack Hub 注册中使用的订阅收取这些资源的使用费用。If that tenant is still using resources on Azure Stack Hub, their usage is charged to the subscription used in the initial Azure Stack Hub registration.

parametersParameters

参数Parameter 说明Description
registrationSubscriptionIdregistrationSubscriptionId 注册的订阅 ID。Subscription ID for the registration.
resourceGroupresourceGroup 注册的资源组。The resource group for the registration.
registrationNameregistrationName 注册的名称。The name of the registration.
customerSubscriptionIdcustomerSubscriptionId 客户订阅 ID。The customer subscription ID. 客户订阅 ID 区分大小写。The customer subscription ID is case sensitive.

PowerShellPowerShell

使用 Remove-AzureRmResource cmdlet 删除租户。Use the Remove-AzureRmResource cmdlet to remove a tenant. 连接到 Azure Stack Hub,然后从提升的提示符运行以下 cmdlet:Connect to Azure Stack Hub, and then from an elevated prompt run the following cmdlet:

Remove-AzureRmResource -ResourceId "subscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}" -ApiVersion 2017-06-01

API 调用API call

可以使用 DELETE 操作删除租户映射。You can remove tenant mappings using the DELETE operation.

Operation:DELETEOperation: DELETE
RequestURIsubscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}?api-version=2017-06-01 HTTP/1.1RequestURI: subscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}?api-version=2017-06-01 HTTP/1.1
响应:204 无内容Response: 204 No Content
响应正文:空Response Body: Empty

后续步骤Next steps