You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Azure定价API获取企业协议(EA)专属Azure VM定价?

问题描述

尝试通过Azure定价API获取企业协议(EA)专属的Azure VM定价,使用的PowerShell命令如下:

Invoke-RestMethod -Uri "https://prices.azure.com/api/retail/prices?currencyCode=CAD&CustomerEntityId=4885879&`$filter=serviceName eq 'Virtual Machines' and armRegionName eq 'canadacentral' and contains(productName, 'Windows') and armSkuName eq 'Standard_D8als_v6' and priceType eq 'Consumption' and meterName eq 'D8als v6'"

但返回结果始终显示CustomerEntityId为Default、CustomerEntityType为Retail,而非EA专属定价,示例响应如下:

BillingCurrency : CAD CustomerEntityId : Default
CustomerEntityType : Retail Items : {@{currencyCode=CAD;
tierMinimumUnits=0.0; retailPrice=1.0416; unitPrice=1.0416;
armRegionName=canadacentral; location=CA Central;
effectiveStartDate=2024-09-01T00:00:00Z; meterId=ef0e76f0-aa8a-59c6-9627-0a7252efb0a9; meterName=D8als v6;
productId=DZH318Z0F5DN; skuId=DZH318Z0F5DN/01Q6;
productName=Virtual Machines Dalsv6 Series Windows; skuName=D8als v6; serviceName=Virtual Machines;
serviceId=DZH313Z7MMC8; serviceFamily=Compute; unitOfMeasure=1
Hour; type=Consumption; isPrimaryMeterRegion=True; armSkuName=Standard_D8als_v6}} NextPageLink
: Count : 1

已尝试设置CustomerEntityId,但仍默认返回零售定价,无法切换至目标实体ID,该如何修改命令以获取EA专属定价?

解决方案

你当前使用的是Azure零售定价API(https://prices.azure.com/api/retail/prices),这个API仅提供零售价格,不支持EA协议的专属定价查询,即使添加CustomerEntityId参数也无效。要获取EA专属定价,必须使用EA专属的计费API端点,并完成身份验证:

1. 获取EA API访问凭证

  • 登录EA管理门户(需拥有EA管理员权限)
  • 进入Reporting > API Access页面
  • 复制你的EA注册编号(Enrollment Number)和API密钥(API Key)

2. 使用EA专属定价API构造请求

EA定价API的端点格式为:https://ea.azure.com/rest/{EnrollmentNumber}/prices,需携带API密钥作为身份验证头,同时添加筛选参数获取目标VM定价。

示例PowerShell命令:

# 替换为你的EA注册编号和API密钥
$enrollmentNumber = "你的EA注册编号"
$apiKey = "你的EA API密钥"

# 构造请求头
$headers = @{
    "Authorization" = "Bearer $apiKey"
    "Content-Type"  = "application/json"
}

# 构造请求URI,添加筛选参数
$uri = "https://ea.azure.com/rest/$enrollmentNumber/prices?currencyCode=CAD&region=canadacentral&serviceName=Virtual Machines&skuName=Standard_D8als_v6&os=Windows"

# 发送请求
Invoke-RestMethod -Uri $uri -Headers $headers

关键说明

  • EA定价API返回的价格会包含你的EA协议专属折扣,与零售价格不同
  • 若需要更精细的筛选(比如特定计费维度),可以参考EA API文档添加更多查询参数
  • 确保你的API密钥拥有足够的权限(至少需要"Report Reader"角色)

内容的提问来源于stack exchange,提问作者Stalin Rijal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 23:17:05