获取产品的 SKU 列表(按国家/地区)
可以使用合作伙伴中心 API 获取特定产品所在国家/地区提供的 SKU 集合。
必备条件
合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和 App+用户凭据进行身份验证。
产品标识符。
C#
若要获取产品的 SKU 列表,
按照“按 ID 获取产品”中的步骤获取特定产品的操作的接口。
从接口中,选择 Skus 属性以获取具有 SKU 可用操作的接口。
调用 Get () 或 GetAsync () 方法来检索产品的可用 SKU 集合。
(可选) 使用 ByReservationScope () 方法选择预留范围。
(可选) 使用 ByTargetSegment () 方法在调用 Get () 或 GetAsync () 之前按目标段筛选 SKU。
IAggregatePartner partnerOperations;
string countryCode;
string productId;
string productIdForAzureReservation;
string targetSegment;
// Get the available SKUs.
var skus = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.Get();
// Get the available SKUs, filtered by target segment.
var segmentSkus = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ByTargetSegment(targetSegment).Get();
// Get the skus for an Azure reservation product which are applicable to Microsoft Azure (MS-AZR-0145P) subscriptions only.
var skus = partnerOperations.Products.ByCountry(countryCode).ById(productIdForAzureReservation).Skus.Get();
// Get the skus for an Azure reservation product which are applicable to Azure plans only.
var skus = partnerOperations.Products.ByCountry(countryCode).ById(productIdForAzureReservation).Skus.ByReservationScope("AzurePlan").Get();
Java
合作伙伴通常使用合作伙伴中心 Java SDK 来管理其合作伙伴中心资源。 它是由合作伙伴社区维护的开源项目。 由于此模块由合作伙伴社区维护,因此 Microsoft 不提供官方支持。 如果遇到问题,可以从社区获取帮助或在 GitHub 上创建问题。
若要获取产品的 SKU 列表,
按照“按 ID 获取产品”中的步骤获取特定产品的操作的接口。
从接口中,选择 getSkus 函数以获取具有 SKU 可用操作的接口。
调用 get () 函数以检索产品的可用 SKU 的集合。
(可选) 使用 byTargetSegment () 函数在调用 get () 函数之前按目标段筛选 SKU。
// IAggregatePartner partnerOperations;
// String countryCode;
// String productId;
// String targetSegment;
// Get the available SKUs.
ResourceCollection<Sku> skus = partnerOperations.getProducts().byCountry(countryCode).byId(productId).getSkus().get();
// Get the available SKUs, filtered by target segment.
var segmentSkus = partnerOperations.getProducts().byCountry(countryCode).byId(productId).getSkus().byTargetSegment(targetSegment).get();
PowerShell
合作伙伴通常使用合作伙伴中心 PowerShell 模块来管理其合作伙伴中心资源。 它是由合作伙伴社区维护的开源项目。 由于此模块由合作伙伴社区维护,因此 Microsoft 不提供官方支持。 如果遇到问题,可以从社区获取帮助或在 GitHub 上创建问题。
若要获取产品的 SKU 列表,
执行 Get-PartnerProductSku 命令。
(可选) 指定按目标段筛选 SKU 的 Segment 参数。
# $productId
# $targetSegment
# Get the available SKUs.
Get-PartnerProductSku -ProductId $productId
# Get the available SKUs, filtered by target segment.
Get-PartnerProductSku -ProductId $productId -Segment $targetSegment
REST 请求
请求语法
| 方法 | 请求 URI |
|---|---|
| GET | {baseURL}/v1/products/{product-id}/skus?country={country-code}&targetSegment={target-segment} HTTP/1.1 |
URI 参数
使用以下路径和查询参数获取产品的 SKU 列表。
| 名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
| product-id | 字符串 | 是 | 标识产品的字符串。 |
| country-code | string | 是 | 国家/地区 ID。 |
| target-segment | 字符串 | 否 | 标识用于筛选的目标段的字符串。 |
| reservationScope | 字符串 | 否 | 查询 Azure 预留产品 SKU 列表时,请指定 reservationScope=AzurePlan 获取适用于 AzurePlan 的 SKU 列表。 排除此参数以获取适用于 Microsoft Azure (MS-AZR-0145P) 订阅的 Azure 预留产品的 SKU 列表。 |
请求标头
有关详细信息,请参阅合作伙伴中心 REST 标头。
请求正文
无。
请求示例
获取给定产品的 SKU 列表:
GET http://api.partnercenter.microsoft.com/v1/products/DZH318Z0BPS6/skus?country=US HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 18b41adf-29b5-48eb-b14f-c9683a4e5b7d
MS-CorrelationId: e75c1060-852e-4b49-92b0-cd15167a0d51
获取 Azure 预留产品的 SKU 列表。 仅包括适用于 Azure 计划的 SKU,而不是 Microsoft Azure (MS-AZR-0145P) 订阅:
GET http://api.partnercenter.microsoft.com/v1/products/DZH318Z0BQ5S/skus?country=US&reservationScope=AzurePlan HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 18b41adf-29b5-48eb-b14f-c9683a4e5b7d
MS-CorrelationId: e75c1060-852e-4b49-92b0-cd15167a0d51
获取 Azure 预留产品的 SKU 列表。 仅包括适用于 Microsoft Azure (MS-AZR-0145P) 订阅而不是 Azure 计划的 SKU:
GET http://api.partnercenter.microsoft.com/v1/products/DZH318Z0BQ5S/skus?country=US HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 18b41adf-29b5-48eb-b14f-c9683a4e5b7d
MS-CorrelationId: e75c1060-852e-4b49-92b0-cd15167a0d51
REST 响应
如果成功,响应正文包含 SKU 资源的集合。
响应的成功和错误代码
每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 合作伙伴中心错误代码。
此方法返回以下错误代码:
| HTTP 状态代码 | 错误代码 | 说明 |
|---|---|---|
| 403 | 400030 | 不允许访问请求的 targetSegment。 |
| 404 | 400013 | 找不到父产品。 |
Azure VM 预留 (Azure 计划) 的响应示例
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
MS-CorrelationId: e75c1060-852e-4b49-92b0-cd15167a0d51,e75c1060-852e-4b49-92b0-cd15167a0d51
MS-RequestId: 18b41adf-29b5-48eb-b14f-c9683a4e5b7d,18b41adf-29b5-48eb-b14f-c9683a4e5b7d
X-Locale: en-US,en-US
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcbWFtZW5kZVxkZXZcZHBzLXJwZVxSUEUuUGFydG5lci5TZXJ2aWNlLkNhdGFsb2dcV2ViQXBpc1xDYXRhbG9nU2VydmljZS5WMi5XZWJcdjFccHJvZHVjdHNcRFpIMzE4WjBCUTVTXHNrdXM=?=
X-Powered-By: ASP.NET
Date: Thu, 15 Mar 2018 21:06:03 GMT
Content-Length: 50917
{
"totalCount": 40,
"items": [
{
"id": "0001",
"productId": "DZH318Z0BQ5S",
"title": "Reserved VM Instance, Standard_ND12s, US West 2, 1 Year",
"description": "Reserved Virtual Machines Instance, Standard_ND12s, US West 2, 1 Year",
"minimumQuantity": 1,
"maximumQuantity": 999999999,
"isTrial": false,
"supportedBillingCycles": [
"one_time"
],
"purchasePrerequisites": [
"AzureSubscriptionRegistration",
"InventoryCheck"
],
"provisioningVariables": [
"Scope",
"SubscriptionId"
],
"dynamicAttributes": {
"armSkuName": "Standard_ND12s",
"cores": "12",
"ram": "224",
"skuDisplayName": "ND12",
"category": "GPU",
"armRegionName": "westus2",
"duration": "1Year",
"region": "US West 2",
"diskType": "Hdd"
},
"links": {
"availabilities": {
"uri": "/products/DZH318Z0BQ5S/skus/0001/availabilities?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/products/DZH318Z0BQ5S/skus/0001?country=US",
"method": "GET",
"headers": []
}
}
},
{
"id": "0002",
"productId": "DZH318Z0BQ5S",
"title": "Reserved VM Instance, Standard_ND6s, US West 2, 1 Year",
"description": "Reserved Virtual Machines Instance, Standard_ND6s, US West 2, 1 Year",
"minimumQuantity": 1,
"maximumQuantity": 999999999,
"isTrial": false,
"supportedBillingCycles": [
"one_time"
],
"purchasePrerequisites": [
"AzureSubscriptionRegistration",
"InventoryCheck"
],
"provisioningVariables": [
"Scope",
"SubscriptionId"
],
"dynamicAttributes": {
"armSkuName": "Standard_ND6s",
"cores": "6",
"ram": "112",
"skuDisplayName": "ND6",
"category": "GPU",
"armRegionName": "westus2",
"duration": "1Year",
"region": "US West 2",
"diskType": "Hdd"
},
"links": {
"availabilities": {
"uri": "/products/DZH318Z0BQ5S/skus/0002/availabilities?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/products/DZH318Z0BQ5S/skus/0002?country=US",
"method": "GET",
"headers": []
}
}
}
[...]
],
"links": {
"self": {
"uri": "/products/DZH318Z0BQ5S/skus?country=US",
"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: e75c1060-852e-4b49-92b0-cd15167a0d51,e75c1060-852e-4b49-92b0-cd15167a0d51
MS-RequestId: 18b41adf-29b5-48eb-b14f-c9683a4e5b7d,18b41adf-29b5-48eb-b14f-c9683a4e5b7d
X-Locale: en-US,en-US
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcbWFtZW5kZVxkZXZcZHBzLXJwZVxSUEUuUGFydG5lci5TZXJ2aWNlLkNhdGFsb2dcV2ViQXBpc1xDYXRhbG9nU2VydmljZS5WMi5XZWJcdjFccHJvZHVjdHNcRFpIMzE4WjBCUTVTXHNrdXM=?=
X-Powered-By: ASP.NET
Date: Thu, 15 Mar 2018 21:06:03 GMT
Content-Length: 50917
{
"totalCount": 40,
"items": [
{
{
"id": "0001",
"productId": "CFQ7TTC0LH18",
"title": "Microsoft 365 Business Basic",
"description": "Best for businesses that need professional email, cloud file storage, and online meetings & chat. Desktop versions of Office apps like Excel, Word, and PowerPoint not included. For businesses with up to 300 employees.",
"minimumQuantity": 1,
"maximumQuantity": 300,
"isTrial": false,
"supportedBillingCycles": [
"annual",
"monthly"
],
"purchasePrerequisites": [
"MicrosoftCloudAgreement"
],
"inventoryVariables": [],
"provisioningVariables": [],
"actions": [
"Refund"
],
"dynamicAttributes": {
"isMicrosoftProduct": true,
"hasConstraints": true,
"isAddon": false,
"prerequisiteSkus": [],
"isSoftwareAssuranceApplicable": false,
"upgradeTargetOffers": [
"CFQ7TTC0LDPB:0001",
"CFQ7TTC0LF8Q:0001"
…
],
"provisioningId": "3b555118-da6a-4418-894f-7df1e2096870",
"internal": false
},
"links": {
"availabilities": {
"uri": "/products/CFQ7TTC0LH18/skus/0001/availabilities?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/products/CFQ7TTC0LH18/skus/0001?country=US",
"method": "GET",
"headers": []
}
}
} [...]
],
"links": {
"self": {
"uri": "/products/DZH318Z0BQ5S/skus?country=US",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "Collection"
}
}