Azure SQL数据库的“定价层”详细信息 - powershell

时间:2016-02-24 19:52:37

标签: azure azure-powershell azure-sql-database

是否可以通过PowerShell获取Azure SQL数据库的定价层详细信息?谢谢。

2 个答案:

答案 0 :(得分:6)

您可以从powershell调用其余的api来获取定价详细信息: new-azure-billing-apis-available

有关定价详情,您可以拨打价目表api:Get price and metadata information for resources used in an Azure subscription

答案 1 :(得分:1)

您可以阅读Azure新的价目表API以获取有关您资源的定价信息。 https://docs.microsoft.com/en-us/azure/billing/billing-usage-rate-card-overview

阅读整篇文章很繁琐,但您可以参考此任务的示例帖子How to calculate Azure SQL databases price by PowerShell

以下是代码段

$Ret = Invoke-AzureRestGetAPI -Uri "https://management.azure.com/subscriptions/$subscriptionid/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&`$filter=OfferDurableId eq 'MS-AZR-$OfferDurableId' and Currency eq '$Currency' and Locale eq '$Locale' and RegionInfo eq '$RegionInfo'" 

$Sum = 0 
$Ret.Meters | ForEach-Object { 
    If ($_.MeterSubCategory -eq "SQL Database") { 
        $Sum += $_.MeterRates.0 
        Write-Host ($_ | ConvertTo-Json -depth 4) 
        Write-Host "" 
    } 
} 
相关问题