获取 SKU 的可用性列表(按国家/地区)
本文介绍如何获取指定产品和 SKU 的特定国家/地区的可用性集合。
必备条件
合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和 App+用户凭据进行身份验证。
产品标识符。
SKU 标识符。
一个国家/ 地区。
C#
按照 ID 获取 SKU 中的步骤获取特定 SKU 操作的接口。
从 SKU 接口中,选择 Availabilityabilities 属性以获取包含操作的接口,以获得可用性。
(可选) 使用 ByTargetSegment () 方法按目标段筛选可用性。 除非盈利性以外的所有段都将返回(如果未包含)。 需要专门通过非盈利组织才能获得非营利性。
调用 Get () 或 GetAsync () 检索此 SKU 的可用性集合。
IAggregatePartner partnerOperations;
string countryCode;
string productId;
string skuId;
string targetSegment;
string productIdForAzureReservation;
string skuIdForAzureReservation;
// Get the availabilities.
var availabilities = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Availabilities.Get();
// Get the availabilities, filtered by target segment.
var availabilities = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Availabilities.BySegment(targetSegment).Get();
// Get the availabilities for an Azure reservation product and sku which are applicable to Microsoft Azure (MS-AZR-0145P) subscriptions only.
var availabilities = partnerOperations.Products.ByCountry(countryCode).ById(productIdForAzureReservation).Skus.ById(skuIdForAzureReservation).Availabilities.ByReservationScope("AzurePlan").Get();
// Get the availabilities for an Azure reservation product and sku which are applicable to Azure plans only.
var availabilities = partnerOperations.Products.ByCountry(countryCode).ById(productIdForAzureReservation).Skus.ById(skuIdForAzureReservation).Availabilities.Get();
REST 请求
请求语法
| 方法 | 请求 URI |
|---|---|
| GET | {baseURL}/v1/products/{product-id}/skus/{sku-id}/availabilityabilities?country={country-code}&targetSegment={target-segment} HTTP/1.1 |
URI 参数
使用以下路径和查询参数获取 SKU 的可用性列表。
| 名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
| product-id | 字符串 | 是 | 标识产品的字符串。 |
| sku-id | string | 是 | 标识 SKU 的字符串。 |
| country-code | string | 是 | 国家/地区 ID。 |
| target-segment | 字符串 | 否 | 标识用于筛选的目标段的字符串。 除非盈利性以外的所有段都将返回(如果未包含)。 需要专门通过非盈利组织才能获得非营利性。 |
| reservationScope | 字符串 | 否 | 查询 Azure 预留 SKU 的可用性列表时,请指定 reservationScope=AzurePlan 获取适用于 AzurePlan 的可用性列表。 排除此参数以获取适用于 Microsoft Azure (MS-AZR-0145P) 订阅的可用性列表。 |
请求标头
有关详细信息,请参阅合作伙伴中心 REST 标头。
请求正文
无。
请求示例
按国家/地区分类的 SKU 可用性
按照以下示例按国家/地区获取给定 SKU 的可用性列表:
GET http:// api.partnercenter.microsoft.com/v1/products/DZH318Z0BQ3Q/skus/0001/availabilities?country=US HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 70324727-62d8-4195-8f99-70ea25058d02
MS-CorrelationId: 83b644b5-e54a-4bdc-b354-f96c525b3c58
azure 计划) (VM 预留的可用性
按照以下示例获取 Azure VM 预留 SKU 国家/地区的可用性列表。 此示例适用于适用于 Azure 计划的 SKU:
GET https://api.partnercenter.microsoft.com/v1/products/DZH318Z0BQ3Q/skus/0001/availabilities?country=US&targetView=AzureReservationsVM&reservationScope=AzurePlan HTTP/1.1
Authorization: Bearer
Accept: application/json
MS-RequestId: 031160b2-b0b0-4d40-b2b1-aaa9bb84211d
MS-CorrelationId: 7c1f6619-c176-4040-a88f-2c71f3ba4533
Microsoft Azure (MS-AZR-0145P) 订阅的 VM 预留可用性
按照以下示例获取适用于 Microsoft Azure (MS-AZR-0145P) 订阅的 Azure VM 预留国家/地区的可用性列表。
GET https://api.partnercenter.microsoft.com/v1/products/DZH318Z0BQ3Q/skus/0001/availabilities?country=US&targetView=AzureAzureReservationsVM HTTP/1.1
Authorization: Bearer
Accept: application/json
MS-RequestId: 031160b2-b0b0-4d40-b2b1-aaa9bb84211d
MS-CorrelationId: 7c1f6619-c176-4040-a88f-2c71f3ba4533
REST 响应
如果成功,响应正文包含 可用性 资源的集合。
响应的成功和错误代码
每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 合作伙伴中心错误代码。
此方法返回以下错误代码:
| HTTP 状态代码 | 错误代码 | 说明 |
|---|---|---|
| 403 | 400030 | 不允许访问请求 的 targetSegment 。 |
Azure VM 预留 (Azure 计划) 的响应示例
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
MS-CorrelationId: 83b644b5-e54a-4bdc-b354-f96c525b3c58,83b644b5-e54a-4bdc-b354-f96c525b3c58
MS-RequestId: 70324727-62d8-4195-8f99-70ea25058d02,70324727-62d8-4195-8f99-70ea25058d02
X-Locale: en-US,en-US
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcbWFtZW5kZVxkZXZcZHBzLXJwZVxSUEUuUGFydG5lci5TZXJ2aWNlLkNhdGFsb2dcV2ViQXBpc1xDYXRhbG9nU2VydmljZS5WMi5XZWJcdjFccHJvZHVjdHNcRFpIMzE4WjBCUTNRXHNrdXNcMDAwMVxhdmFpbGFiaWxpdGllcw==?=
X-Powered-By: ASP.NET
Date: Wed, 14 Mar 2018 22:19:37 GMT
Content-Length: 808
{
"totalCount": 1,
"items": [
{
"id": "DZH318XZXVNF",
"productId": "DZH318Z0BQ3Q",
"skuId": "0001",
"catalogItemId": "DZH318Z0BQ3Q:0001:DZH318XZXVNF",
"defaultCurrency": {
"code": "USD",
"symbol": "$"
},
"segment": "commercial",
"country": "US",
"isPurchasable": true,
"isRenewable": false,
"terms": [{
"duration": "P1Y",
"description": "1 Year Prepaid"
}],
"product": { ... },
"sku": { ... },
"links": {
"self": {
"uri": "/products/DZH318Z0BQ3Q/skus/0001/availabilities/DZH318Z0HMKQ?country=US",
"method": "GET",
"headers": []
}
}
}
],
"links": {
"self": {
"uri": "/products/DZH318Z0BQ3Q/skus/0001/availabilities?country=US&targetSegment=commercial",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "Collection"
}
}
基于新商业许可证的服务的响应示例
注意
基于许可证的服务的新商业体验涵盖许多新功能,可供所有云解决方案提供商 (CSP) 使用。 有关详细信息,请参阅新商务体验概述。
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
MS-CorrelationId: 83b644b5-e54a-4bdc-b354-f96c525b3c58,83b644b5-e54a-4bdc-b354-f96c525b3c58
MS-RequestId: 70324727-62d8-4195-8f99-70ea25058d02,70324727-62d8-4195-8f99-70ea25058d02
X-Locale: en-US,en-US
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcbWFtZW5kZVxkZXZcZHBzLXJwZVxSUEUuUGFydG5lci5TZXJ2aWNlLkNhdGFsb2dcV2ViQXBpc1xDYXRhbG9nU2VydmljZS5WMi5XZWJcdjFccHJvZHVjdHNcRFpIMzE4WjBCUTNRXHNrdXNcMDAwMVxhdmFpbGFiaWxpdGllcw==?=
X-Powered-By: ASP.NET
Date: Wed, 14 Mar 2018 22:19:37 GMT
Content-Length: 808
{
"id": "CFQ7TTC0K971",
"productId": "CFQ7TTC0LH18",
"skuId": "0001",
"catalogItemId": "CFQ7TTC0LH18:0001:CFQ7TTC0K971",
"defaultCurrency": {
"code": "USD",
"symbol": "$"
},
"segment": "commercial",
"country": "US",
"isPurchasable": true,
"isRenewable": true,
"renewalInstructions": [
{
"applicableTermIds": [
"5aeco6mffyxo"
],
"renewalOptions": [
{
"renewToId": "CFQ7TTC0LH18:0001",
"isAutoRenewable": true
}
]
},
…
],
"terms": [
{
"id": "5aeco6mffyxo",
"duration": "P1Y",
"description": "One-Year commitment for monthly/yearly billing",
"billingCycle": "Annual",
"cancellationPolicies": [
{
"refundOptions": [
{
"sequenceId": 0,
"type": "Full",
"expiresAfter": "P1D"
}
]
}
]
},
…
],
"links": {
"self": {
"uri": "/products/CFQ7TTC0LH18/skus/0001/availabilities/CFQ7TTC0K971?country=US",
"method": "GET",
"headers": []
}
},
"links": {
"availabilities": {
"uri": "/products/CFQ7TTC0LH18/skus/0001/availabilities?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/products/CFQ7TTC0LH18/skus/0001?country=US",
"method": "GET",
"headers": []
}
}
}
}