取得訂用帳戶的註冊狀態

如何取得已啟用購買 Azure 保留 VM 實例的客戶訂用帳戶訂用帳戶註冊狀態。

若要使用合作夥伴中心 API 購買 Azure 保留的 VM 實例,您必須至少有一個現有的 CSP Azure 訂用帳戶。 註冊訂用帳戶方法可讓您註冊現有的 CSP Azure 訂用帳戶,讓其能夠購買 Azure 保留的 VM 實例。 這個方法可讓您擷取該註冊的狀態。

必要條件

  • 認證,如合作夥伴中心驗證所述。 此案例支援使用獨立應用程式和 App+使用者認證進行驗證。

  • 客戶識別碼 (customer-tenant-id)。 如果您不知道客戶的識別碼,您可以選取 [客戶] 工作區,然後從客戶清單中選取客戶,然後從客戶清單中查詢該識別碼,然後查閱合作夥伴中心。 在客戶的 [帳戶] 頁面上,尋找 [客戶帳戶資訊] 區段中的 [Microsoft 識別碼] 。 Microsoft 識別碼與客戶識別碼 () customer-tenant-id 相同。

  • 訂用帳戶識別碼。

C#

若要取得訂用帳戶的註冊狀態,請先使用 IAggregatePartner.Customers.ById 方法來識別客戶。 然後,使用訂用帳戶識別碼呼叫 Subscription.ById () 方法來識別訂用帳戶,以取得訂用帳戶作業的介面。 接下來,使用 RegistrationStatus 屬性來取得目前訂閱註冊狀態作業的介面,並呼叫 Get 或GetAsync方法來擷取SubscriptionRegistrationStatus物件。

// IAggregatePartner partnerOperations;
// var selectedCustomerId;
// var selectedSubscriptionId;

// Retrieve a subscription's registration status details.
var subscriptionRegistrationDetails = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(selectedSubscriptionId).RegistrationStatus.Get();

REST 要求

要求的語法

方法 要求 URI
GET {baseURL}/v1/customers/{customer-id}/subscriptions/{subscription-id}/registrationstatus HTTP/1.1

URI 參數

使用下列路徑參數來識別客戶和訂用帳戶。

名稱 類型 必要 描述
customer-id string Yes 識別客戶的 GUID 格式字串。
subscription-id string Yes 識別訂用帳戶的 GUID 格式字串。

要求標頭

如需詳細資訊,請參閱合作夥伴中心 REST 標頭

要求本文

無。

要求範例

GET https://api.partnercenter.microsoft.com/v1/customers/<customer-id>/subscriptions/<subscription-id>/registrationstatus HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3123
MS-CorrelationId: ec8f62e5-1d92-47e9-8d5d-1924af105123
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

REST 回應

如果成功,回應本文會包含 SubscriptionRegistrationStatus 資源。

回應成功和錯誤碼

每個回應都隨附 HTTP 狀態碼,會指出成功與否以及其他的偵錯資訊。 請使用網路追蹤工具來讀取此錯誤碼、錯誤類型和其他參數。 如需完整清單,請參閱錯誤碼

回應範例

HTTP/1.1 200 OK
Content-Length: 177
Content-Type: application/json; charset=utf-8
MS-CorrelationId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3123
MS-RequestId: ec8f62e5-1d92-47e9-8d5d-1924af105123
MS-CV: InswEQre402koceL.0
MS-ServerId: 030020344

{
    "subscriptionId":"<subscription-id>",
    "status":"NotRegistered",
    "attributes":{
        "objectType":"SubscriptionRegistrationStatus"
    }
}