您可以使用 Azure 計費和使用量 API,以程式設計方式取得計費帳戶的點數餘額。
以下顯示的範例使用 REST API。 目前不支援 PowerShell 和 Azure CLI。
尋找您有權存取的帳單設定檔
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts?$expand=billingProfiles&api-version=2019-10-01-preview
API 回應會傳回計費帳戶及其帳單設定檔的清單。
{
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"name": "5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"properties": {
"accountId": "5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"accountStatus": "Active",
"accountType": "Enterprise",
"agreementType": "MicrosoftCustomerAgreement",
"billingProfiles": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx",
"name": "PBFV-xxxx-xxx-xxx",
"properties": {
"address": {
"addressLine1": "AddressLine1",
"city": "City",
"companyName": "CompanyName",
"country": "Country",
"postalCode": "xxxxx",
"region": "Region"
},
"currency": "USD",
"displayName": "Development",
"hasReadAccess": true,
"invoiceDay": 5,
"invoiceEmailOptIn": true
},
"type": "Microsoft.Billing/billingAccounts/billingProfiles"
}
],
"displayName": "Contoso",
"hasReadAccess": true,
},
"type": "Microsoft.Billing/billingAccounts"
}
]
}
使用帳單設定檔的 displayName
屬性,識別您要檢查點數餘額的帳單設定檔。 複製帳單設定檔的 id
。 例如,如果您想要檢查 Development 帳單設定檔的點數餘額,您會複製 /providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx
。 將此值貼在某處,以便您在下一個步驟中使用。
取得 Azure 點數餘額
提出下列要求,並以在第一個步驟複製的 id
取代 <billingProfileId>
(/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx
)。
GET https://management.azure.com<billingProfileId>/providers/Microsoft.Consumption/credits/balanceSummary?api-version=2019-10-01
API 回應會傳回帳單設定檔的預估和目前餘額。
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx/providers/Microsoft.Consumption/credits/balanceSummary/57c2e8df-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "57c2e8df-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Microsoft.Consumption/credits/balanceSummary",
"eTag": null,
"properties": {
"balanceSummary": {
"estimatedBalance": {
"currency": "USD",
"value": 996.13
},
"currentBalance": {
"currency": "USD",
"value": 997.87
}
},
"pendingCreditAdjustments": {
"currency": "USD",
"value": 0.0
},
"expiredCredit": {
"currency": "USD",
"value": 0.0
},
"pendingEligibleCharges": {
"currency": "USD",
"value": -1.74
}
}
}
元素名稱 |
描述 |
estimatedBalance |
您在考量所有計費交易和擱置交易後所擁有的估計點數金額。 |
currentBalance |
截至最後一張發票為止的點數金額。 其中不包含任何擱置交易。 |
pendingCreditAdjustments |
尚未開立發票的調整 (如退款)。 |
expiredCredit |
自上一張發票以來過期的點數。 |
pendingEligibleCharges |
尚未開立發票的適用點數費用。 |
取得點數清單
提出下列要求,並以在第一個步驟複製的 id
取代 <billingProfileId>
(/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx
)。
GET https://management.azure.com<billingProfileId>/providers/Microsoft.Consumption/lots?api-version=2019-10-01
API 回應會傳回帳單設定檔的 Azure 點數清單。
{
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx/providers/Microsoft.Consumption/lots/f2ecfd94-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "f2ecfd94-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Microsoft.Consumption/lots",
"eTag": null,
"properties": {
"originalAmount": {
"currency": "USD",
"value": 500.0
},
"closedBalance": {
"currency": "USD",
"value": 500.0
},
"source": "Azure Promotional Credit",
"startDate": "09/18/2019 21:47:31",
"expirationDate": "09/18/2020 21:47:30",
"poNumber": ""
}
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/xxxx-xxxx-xxx-xxx/providers/Microsoft.Consumption/lots/4ea40eb5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "4ea40eb5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Microsoft.Consumption/lots",
"eTag": null,
"properties": {
"originalAmount": {
"currency": "USD",
"value": 500.0
},
"closedBalance": {
"currency": "USD",
"value": 497.87
},
"source": "Azure Promotional Credit",
"startDate": "09/18/2019 21:47:31",
"expirationDate": "09/18/2020 21:47:30",
"poNumber": ""
}
}
]
}
元素名稱 |
描述 |
originalAmount |
原始點數金額。 |
closedBalance |
截至最後一張發票為止的餘額。 |
source |
可定義取得點數之人員/方式的來源。 |
startDate |
點數生效的日期。 |
expirationDate |
點數到期的日期。 |
poNumber |
點數計費發票的採購單號碼。 |
取得對點數餘額造成影響的交易
提出下列要求,並以在第一個步驟複製的 id
取代 <billingProfileId>
(providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx
)。 您需要傳遞 startDate 和 endDate,以取得所需持續時間的交易。
GET https://management.azure.com<billingProfileId>/providers/Microsoft.Consumption/events?api-version=2019-10-01&startDate=2018-10-01T00:00:00.000Z&endDate=2019-10-11T12:00:00.000Z?api-version=2019-10-01
API 回應會傳回所有影響帳單設定檔之點數餘額的交易。
{
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx`/providers/Microsoft.Consumption/events/e2032eb5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "e2032eb5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Microsoft.Consumption/events",
"eTag": null,
"properties": {
"transactionDate": "10/11/2019",
"description": "Credit eligible charges as of 10/11/2019",
"newCredit": {
"currency": "USD",
"value": 0.0
},
"adjustments": {
"currency": "USD",
"value": 0.0
},
"creditExpired": {
"currency": "USD",
"value": 0.0
},
"charges": {
"currency": "USD",
"value": -1.74
},
"closedBalance": {
"currency": "USD",
"value": 998.26
},
"eventType": "PendingCharges",
"invoiceNumber": ""
}
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx/providers/Microsoft.Consumption/events/381efd80-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "381efd80-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Microsoft.Consumption/events",
"eTag": null,
"properties": {
"transactionDate": "09/18/2019",
"description": "New credit added on 09/18/2019",
"newCredit": {
"currency": "USD",
"value": 500.0
},
"adjustments": {
"currency": "USD",
"value": 0.0
},
"creditExpired": {
"currency": "USD",
"value": 0.0
},
"charges": {
"currency": "USD",
"value": 0.0
},
"closedBalance": {
"currency": "USD",
"value": 1000.0
},
"eventType": "PendingNewCredit",
"invoiceNumber": ""
}
}
]
}
元素名稱 |
描述 |
transactionDate |
交易發生的日期。 |
description |
交易的描述。 |
adjustments |
交易的點數調整。 |
creditExpired |
已過期的點數金額。 |
charges |
交易的費用。 |
closedBalance |
交易後的餘額。 |
eventType |
交易的類型。 |
invoiceNumber |
交易計費發票的發票號碼。 暫止交易的的發票號碼會是空的。 |