Azure SQL数据库的定价层详细信息 - PowerShell

3
通过PowerShell获取Azure SQL数据库的定价层详细信息是否可行?谢谢。
2个回答

6

1
你可以阅读Azure的新费率卡API,以获取有关资源定价信息。https://learn.microsoft.com/en-us/azure/billing/billing-usage-rate-card-overview 阅读整篇文章很繁琐,但是你可以参考此示例文章来完成你的任务如何通过PowerShell计算Azure SQL数据库价格 以下是代码片段
$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 "" 
    } 
} 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接