获取订阅注册状态

如何获取已启用用于购买 Azure 虚拟机预留实例的客户订阅的订阅注册状态。

若要使用合作伙伴中心 API 购买 Azure 虚拟机预留实例,必须至少有一个现有的 CSP Azure 订阅。 注册 订阅 方法允许注册现有的 CSP Azure 订阅,使其能够购买 Azure 虚拟机预留实例。 此方法允许检索该注册的状态。

必备条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和应用+用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以通过选择“客户”工作区、客户列表中的“客户”和“帐户”,在合作伙伴中心中查找该 ID。 在客户的“帐户”页上的“客户帐户信息” 部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。

  • 订阅 ID。

C#

若要获取订阅的注册状态,请首先使用带有客户 ID 的 IAggregatePartner.Customers.ById 方法来标识客户。 然后,通过使用订阅 ID 调用 Subscription.ById () 方法来获取订阅操作的接口,以标识订阅。 接下来,使用 RegistrationStatus 属性获取指向当前订阅的注册状态操作的接口,并调用 GetGetAsync 方法来检索 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 标识客户的 GUID 格式字符串。
subscription-id 字符串 标识订阅的 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"
    }
}