|
| 1 | +--- |
| 2 | +author: davidsmatlak |
| 3 | +ms.service: resource-graph |
| 4 | +ms.topic: include |
| 5 | +ms.date: 07/07/2022 |
| 6 | +ms.author: davidsmatlak |
| 7 | +ms.custom: generated |
| 8 | +--- |
| 9 | + |
| 10 | +### Get cost savings summary from Azure Advisor |
| 11 | + |
| 12 | +This query summarizes the cost savings of each [Azure Advisor](../../../../../../articles/advisor/advisor-overview.md) recommendation. |
| 13 | + |
| 14 | +```kusto |
| 15 | +AdvisorResources |
| 16 | +| where type == 'microsoft.advisor/recommendations' |
| 17 | +| where properties.category == 'Cost' |
| 18 | +| extend |
| 19 | + resources = tostring(properties.resourceMetadata.resourceId), |
| 20 | + savings = todouble(properties.extendedProperties.savingsAmount), |
| 21 | + solution = tostring(properties.shortDescription.solution), |
| 22 | + currency = tostring(properties.extendedProperties.savingsCurrency) |
| 23 | +| summarize |
| 24 | + dcount(resources), |
| 25 | + bin(sum(savings), 0.01) |
| 26 | + by solution, currency |
| 27 | +| project solution, dcount_resources, sum_savings, currency |
| 28 | +| order by sum_savings desc |
| 29 | +``` |
| 30 | + |
| 31 | +# [Azure CLI](#tab/azure-cli) |
| 32 | + |
| 33 | +```azurecli-interactive |
| 34 | +az graph query -q "AdvisorResources | where type == 'microsoft.advisor/recommendations' | where properties.category == 'Cost' | extend resources = tostring(properties.resourceMetadata.resourceId), savings = todouble(properties.extendedProperties.savingsAmount), solution = tostring(properties.shortDescription.solution), currency = tostring(properties.extendedProperties.savingsCurrency) | summarize dcount(resources), bin(sum(savings), 0.01) by solution, currency | project solution, dcount_resources, sum_savings, currency | order by sum_savings desc" |
| 35 | +``` |
| 36 | + |
| 37 | +# [Azure PowerShell](#tab/azure-powershell) |
| 38 | + |
| 39 | +```azurepowershell-interactive |
| 40 | +Search-AzGraph -Query "AdvisorResources | where type == 'microsoft.advisor/recommendations' | where properties.category == 'Cost' | extend resources = tostring(properties.resourceMetadata.resourceId), savings = todouble(properties.extendedProperties.savingsAmount), solution = tostring(properties.shortDescription.solution), currency = tostring(properties.extendedProperties.savingsCurrency) | summarize dcount(resources), bin(sum(savings), 0.01) by solution, currency | project solution, dcount_resources, sum_savings, currency | order by sum_savings desc" |
| 41 | +``` |
| 42 | + |
| 43 | +# [Portal](#tab/azure-portal) |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +- Azure portal: <a href="https://portal.azure.com/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/AdvisorResources%0a%7c%20where%20type%20%3d%3d%20%27microsoft.advisor%2frecommendations%27%0a%7c%20where%20properties.category%20%3d%3d%20%27Cost%27%0a%7c%20extend%0a%09resources%20%3d%20tostring(properties.resourceMetadata.resourceId)%2c%0a%09savings%20%3d%20todouble(properties.extendedProperties.savingsAmount)%2c%0a%09solution%20%3d%20tostring(properties.shortDescription.solution)%2c%0a%09currency%20%3d%20tostring(properties.extendedProperties.savingsCurrency)%0a%7c%20summarize%0a%09dcount(resources)%2c%0a%09bin(sum(savings)%2c%200.01)%0a%09by%20solution%2c%20currency%0a%7c%20project%20solution%2c%20dcount_resources%2c%20sum_savings%2c%20currency%0a%7c%20order%20by%20sum_savings%20desc" target="_blank">portal.azure.com</a> |
| 48 | +- Azure Government portal: <a href="https://portal.azure.us/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/AdvisorResources%0a%7c%20where%20type%20%3d%3d%20%27microsoft.advisor%2frecommendations%27%0a%7c%20where%20properties.category%20%3d%3d%20%27Cost%27%0a%7c%20extend%0a%09resources%20%3d%20tostring(properties.resourceMetadata.resourceId)%2c%0a%09savings%20%3d%20todouble(properties.extendedProperties.savingsAmount)%2c%0a%09solution%20%3d%20tostring(properties.shortDescription.solution)%2c%0a%09currency%20%3d%20tostring(properties.extendedProperties.savingsCurrency)%0a%7c%20summarize%0a%09dcount(resources)%2c%0a%09bin(sum(savings)%2c%200.01)%0a%09by%20solution%2c%20currency%0a%7c%20project%20solution%2c%20dcount_resources%2c%20sum_savings%2c%20currency%0a%7c%20order%20by%20sum_savings%20desc" target="_blank">portal.azure.us</a> |
| 49 | +- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/AdvisorResources%0a%7c%20where%20type%20%3d%3d%20%27microsoft.advisor%2frecommendations%27%0a%7c%20where%20properties.category%20%3d%3d%20%27Cost%27%0a%7c%20extend%0a%09resources%20%3d%20tostring(properties.resourceMetadata.resourceId)%2c%0a%09savings%20%3d%20todouble(properties.extendedProperties.savingsAmount)%2c%0a%09solution%20%3d%20tostring(properties.shortDescription.solution)%2c%0a%09currency%20%3d%20tostring(properties.extendedProperties.savingsCurrency)%0a%7c%20summarize%0a%09dcount(resources)%2c%0a%09bin(sum(savings)%2c%200.01)%0a%09by%20solution%2c%20currency%0a%7c%20project%20solution%2c%20dcount_resources%2c%20sum_savings%2c%20currency%0a%7c%20order%20by%20sum_savings%20desc" target="_blank">portal.azure.cn</a> |
| 50 | + |
| 51 | +--- |
0 commit comments