註冊租用戶以追蹤 Azure Stack Hub 中的使用量

本文涵蓋註冊作業的相關詳細資料。 透過這些作業,您可以:

  • 管理租用戶註冊。
  • 管理租用戶使用量追蹤。

將租用戶新增至註冊

當您想要將新租用戶新增至註冊時,可以使用此作業。 租使用者使用量會在與Microsoft Entra租使用者連線的 Azure 訂用帳戶下回報。

您也可以使用此作業來變更與租用戶相關聯的訂用帳戶。 呼叫 PUT 或 New-AzResource PowerShell Cmdlet 以覆寫之前的對應。 如果您正在使用 AzureRM PowerShell 模組,請使用 New-AzureRMResource PowerShell Cmdlet。

您可以建立單一 Azure 訂用帳戶與租用戶的關聯。 如果您嘗試將第二個訂用帳戶新增至現有租用戶,系統就會覆寫第一個訂用帳戶。

使用 API 設定檔

下列註冊 Cmdlet 會要求您在執行 PowerShell 時指定 API 設定檔。 API 設定檔代表一組 Azure 資源提供者和其 API 版本。 這些設定檔可協助您在與多個 Azure 雲端互動時使用正確的 API 版本, 例如,如果您在使用全域 Azure 和 Azure Stack Hub 時使用多個雲端,API 設定檔便會指定一個符合其發行日期的名稱。 您使用的是 2017-09-03 設定檔。

如需 Azure Stack Hub 和 API 設定檔的詳細資訊,請參閱管理 Azure Stack Hub 中的 API 版本設定檔

參數

參數 描述
registrationSubscriptionID 用於進行初始註冊的 Azure 訂用帳戶。
customerSubscriptionID 客戶要用來註冊的 Azure 訂用帳戶 (非 Azure Stack Hub)。 必須透過合作夥伴中心,在雲端解決方案提供者 (CSP) 供應項目中建立。 如果客戶有多個租用戶,請為租用戶建立訂用帳戶以便登入 Azure Stack Hub。 客戶的訂用帳戶識別碼會區分大小寫。
resourceGroup Azure 中用來儲存註冊的資源群組。
registrationName 您 Azure Stack Hub 註冊的名稱。 其為儲存在 Azure 中的物件。 名稱的格式通常是 azurestack-CloudID,其中 CloudID 是您 Azure Stack Hub 部署的雲端識別碼。

注意

租用戶必須向他們所使用的每個 Azure Stack Hub 部署註冊。 如果租用戶使用多個 Azure Stack Hub,請使用租用戶訂用帳戶更新每個部署的初始註冊。

PowerShell

使用 New-AzResource Cmdlet 新增租用戶。 連線到 Azure,然後從提升權限的提示字元中執行下列命令:

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

API 呼叫

作業:PUT
RequestURIsubscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}?api-version=2017-06-01 HTTP/1.1
回應:201 Created
回應本文:空白

列出所有已註冊的租用戶

取得已新增至註冊的所有租用戶清單。

注意

如果尚未註冊租用戶,您就不會收到回應。

參數

參數 描述
registrationSubscriptionId 用於進行初始註冊的 Azure 訂用帳戶。
resourceGroup Azure 中用來儲存註冊的資源群組。
registrationName 您 Azure Stack Hub 部署的註冊名稱。 其為儲存在 Azure 中的物件。 名稱的格式通常是 azurestack-CloudID,其中 CloudID 是您 Azure Stack Hub 部署的雲端識別碼。

PowerShell

使用 Get-AzResource Cmdlet 列出所有註冊的租用戶。 連線到 Azure Stack Hub,然後從提升權限的提示字元中執行下列 Cmdlet:

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

API 呼叫

您可以使用 GET 作業取得所有租用戶對應的清單。

作業:GET
RequestURIsubscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions?api-version=2017-06-01 HTTP/1.1
回應:200
回應本文

{
    "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}"
}

移除租用戶對應

您可以將已新增至註冊的租用戶移除。 如果該租用戶仍在使用 Azure Stack Hub 上的資源,則會向初始 Azure Stack Hub 註冊中使用的訂用帳戶收取其使用量的費用。

參數

參數 描述
registrationSubscriptionId 註冊的訂用帳戶識別碼。
resourceGroup 註冊的資源群組。
registrationName 註冊的名稱。
customerSubscriptionId 客戶的訂用帳戶識別碼。 客戶的訂用帳戶識別碼會區分大小寫。

PowerShell

使用 Remove-AzResource Cmdlet 移除租用戶。 連線到 Azure Stack Hub,然後從提升權限的提示字元中執行下列 Cmdlet:

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

API 呼叫

您可以使用 DELETE 作業移除租用戶對應。

作業:刪除
RequestURIsubscriptions/{registrationSubscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionId}?api-version=2017-06-01 HTTP/1.1
回應:204 沒有內容
回應本文:空白

後續步驟