取得產品 SKU 清單(依國家/地區)
您可以使用合作夥伴中心 API 取得特定產品的國家/地區中可用的 SKU 集合。
先決條件
合作夥伴中心驗證中所述的憑證。 此案例支援使用獨立應用程式和 App+使用者認證進行驗證。
產品標識碼。
C#
若要取得產品的 SKU 清單:
依照 透過 ID 取得產品中的步驟,取得特定產品的作業介面。
從介面中,選取 Skus 屬性,以取得具有 SKU 可用作業的介面。
呼叫 Get() 或 GetAsync() 方法來擷取產品的可用 SKU 集合。
(選擇性)使用 ByReservationScope() 方法來選取保留範圍。
(選擇性)使用 ByTargetSegment() 方法來依目標區段篩選 SKU,再呼叫 GetAsync() 或 GetAsync()。
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 SDK 可用來管理合作夥伴中心資源。 這是合作夥伴社群維護的開放原始碼專案,Microsoft未正式支援。 如果您遇到問題,您可以 從社群 取得協助,或 在 GitHub 上提出問題。
若要取得產品的 SKU 清單:
依照 透過 ID 取得產品中的步驟,獲取特定產品操作介面。
從介面中,選取 getSkus 函式,以取得針對 SKU 可用的操作介面。
呼叫 get() 函式,以擷取產品的可用 SKU 集合。
(選擇性)在呼叫 get() 函式之前,請先使用 byTargetSegment() 函式,依目標區段篩選 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 命令。
(選擇性)指定 Segment 參數,以依目標區段篩選 SKU。
# $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 清單。
名字 | 類型 | 必填 | 描述 |
---|---|---|---|
產品編號 | 字串 | 是的 | 識別產品的字串。 |
國家代碼 | 字串 | 是的 | 國家/地區標識碼。 |
目標區段 | 字串 | 不 | 字串,識別用於篩選的目標區段。 |
預訂範圍 | 字串 | 不 | 查詢 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: aaaa0000-bb11-2222-33cc-444444dddddd
取得 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: aaaa0000-bb11-2222-33cc-444444dddddd
取得 Azure 保留產品的 SKU 清單。 只包含適用於 Microsoft Azure 訂閱(MS-AZR-0145P)的 SKU,而不是 Azure 方案:
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: aaaa0000-bb11-2222-33cc-444444dddddd
REST 回應
如果成功,回應主體會包含 SKU 資源的集合。
回應成功和錯誤碼
每個回應都有一個 HTTP 狀態代碼,指出成功或失敗和其他偵錯資訊。 使用網路追蹤工具來讀取此程式代碼、錯誤類型和其他參數。 如需完整清單,請參閱 合作夥伴中心錯誤碼。
此方法會傳回下列錯誤碼:
HTTP 狀態代碼 | 錯誤碼 | 描述 |
---|---|---|
403 | 400030 | 不允許存取所要求的目標段。 |
404 | 400013 | 找不到父產品。 |
Azure 虛擬機器預訂的回應範例(Azure 計劃)
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd,aaaa0000-bb11-2222-33cc-444444dddddd
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: aaaa0000-bb11-2222-33cc-444444dddddd,aaaa0000-bb11-2222-33cc-444444dddddd
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"
}
}