Skip to content

Commit bb3d8b7

Browse files
Add new category for Azure Spot
1 parent 59a93fb commit bb3d8b7

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

articles/governance/resource-graph/samples/samples-by-table.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: List of sample Azure Resource Graph queries by table
33
description: List sample queries for Azure Resource-Graph. Tables include Resources, ResourceContainers, PolicyResources, and more.
4-
ms.date: 03/08/2022
4+
ms.date: 03/23/2022
55
ms.topic: sample
66
ms.custom: generated
77
---
@@ -64,6 +64,10 @@ details, see [Resource Graph tables](../concepts/query-language.md#resource-grap
6464

6565
[!INCLUDE [azure-resource-graph-samples-table-servicehealthresources](../../../../includes/resource-graph/samples/bytable/servicehealthresources.md)]
6666

67+
## SpotResources
68+
69+
[!INCLUDE [Azure-resource-graph-samples-table-spotresources](../../../../includes/resource-graph/samples/bytable/spotresources.md)]
70+
6771
## Next steps
6872

6973
- Learn more about the [query language](../concepts/query-language.md).
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
author: timwarner-msft
3+
ms.service: resource-graph
4+
ms.topic: include
5+
ms.date: 03/23/2022
6+
ms.author: timwarner
7+
ms.custom: generated
8+
---
9+
10+
### Compare the Spot eviction rate across multiple VM SKUs and regions
11+
12+
This query gets the Spot eviction rate across multiple VM SKUs and regions. Spot eviction rate is presented as a percentage range. The results are sorted by VM SKU and region in ascending order.
13+
14+
```kusto
15+
SpotResources
16+
| where type =~ 'microsoft.compute/skuspotevictionrate/location'
17+
| where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4')
18+
| where location in~ ('eastus', 'southcentralus')
19+
| project skuName = tostring(sku.name), location, spotEvictionRate = tostring(properties.evictionRate)
20+
| order by skuName asc, location asc
21+
```
22+
23+
# [Azure CLI](#tab/azure-cli)
24+
25+
```azurecli
26+
az graph query -q "SpotResources | where type =~ 'microsoft.compute/skuspotevictionrate/location' | where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4') | where location in~ ('eastus', 'southcentralus') | project skuName = tostring(sku.name), location, spotEvictionRate = tostring(properties.evictionRate) | order by skuName asc, location asc"
27+
```
28+
29+
# [Azure PowerShell](#tab/azure-powershell)
30+
31+
```azurepowershell
32+
Search-AzGraph -Query "SpotResources | where type =~ 'microsoft.compute/skuspotevictionrate/location' | where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4') | where location in~ ('eastus', 'southcentralus') | project skuName = tostring(sku.name), location, spotEvictionRate = tostring(properties.evictionRate) | order by skuName asc, location asc"
33+
```
34+
35+
# [Portal](#tab/azure-portal)
36+
37+
:::image type="icon" source="../../../../articles/governance/resource-graph/media/resource-graph-small.png"::: Try this query in Azure Resource Graph Explorer:
38+
39+
- Azure portal: <a href="https://portal.azure.com/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/SpotResources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fskuspotevictionrate%2Flocation%27%0A%7C%20where%20sku.name%20in~%20%28%27standard_d2s_v4%27%2C%20%27standard_d4s_v4%27%29%0A%7C%20where%20location%20in~%20%28%27eastus%27%2C%20%27southcentralus%27%29%0A%7C%20project%20skuName%20%3D%20tostring%28sku.name%29%2C%20location%2C%20spotEvictionRate%20%3D%20tostring%28properties.evictionRate%29%0A%7C%20order%20by%20skuName%20asc%2C%20location%20asc" target="_blank">portal.Azure.com</a>
40+
- Azure Government portal: <a href="https://portal.azure.us/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/SpotResources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fskuspotevictionrate%2Flocation%27%0A%7C%20where%20sku.name%20in~%20%28%27standard_d2s_v4%27%2C%20%27standard_d4s_v4%27%29%0A%7C%20where%20location%20in~%20%28%27eastus%27%2C%20%27southcentralus%27%29%0A%7C%20project%20skuName%20%3D%20tostring%28sku.name%29%2C%20location%2C%20spotEvictionRate%20%3D%20tostring%28properties.evictionRate%29%0A%7C%20order%20by%20skuName%20asc%2C%20location%20asc" target="_blank">portal.Azure.us</a>
41+
- Azure China 21Vianet portal: <a href="https://portal.azure.cn/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/SpotResources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fskuspotevictionrate%2Flocation%27%0A%7C%20where%20sku.name%20in~%20%28%27standard_d2s_v4%27%2C%20%27standard_d4s_v4%27%29%0A%7C%20where%20location%20in~%20%28%27eastus%27%2C%20%27southcentralus%27%29%0A%7C%20project%20skuName%20%3D%20tostring%28sku.name%29%2C%20location%2C%20spotEvictionRate%20%3D%20tostring%28properties.evictionRate%29%0A%7C%20order%20by%20skuName%20asc%2C%20location%20asc" target="_blank">portal.Azure.cn</a>
42+
43+
### Compare the latest Spot price across multiple VM SKUs and regions for an OS type
44+
45+
This query gets the latest Spot price across multiple VM SKUs and regions for an OS type. The results are sorted by price in ascending order.
46+
47+
```kusto
48+
SpotResources
49+
| where type =~ 'microsoft.compute/skuspotpricehistory/ostype/location'
50+
| where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4')
51+
| where properties.osType =~ 'linux'
52+
| where location in~ ('eastus', 'southcentralus')
53+
| project skuName = tostring(sku.name), osType = tostring(properties.osType), location, latestSpotPriceUSD = todouble(properties.spotPrices[0].priceUSD)
54+
| order by latestSpotPriceUSD asc
55+
```
56+
57+
# [Azure CLI](#tab/azure-cli)
58+
59+
```azurecli
60+
az graph query -q "SpotResources | where type =~ 'microsoft.compute/skuspotpricehistory/ostype/location' | where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4') | where properties.osType =~ 'linux' | where location in~ ('eastus', 'southcentralus') | project skuName = tostring(sku.name), osType = tostring(properties.osType), location, latestSpotPriceUSD = todouble(properties.spotPrices[0].priceUSD) | order by latestSpotPriceUSD asc"
61+
```
62+
63+
# [Azure PowerShell](#tab/azure-powershell)
64+
65+
```azurepowershell
66+
Search-AzGraph -Query "SpotResources | where type =~ 'microsoft.compute/skuspotpricehistory/ostype/location' | where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4') | where properties.osType =~ 'linux' | where location in~ ('eastus', 'southcentralus') | project skuName = tostring(sku.name), osType = tostring(properties.osType), location, latestSpotPriceUSD = todouble(properties.spotPrices[0].priceUSD) | order by latestSpotPriceUSD asc"
67+
```
68+
69+
# [Portal](#tab/azure-portal)
70+
71+
:::image type="icon" source="../../../../articles/governance/resource-graph/media/resource-graph-small.png"::: Try this query in Azure Resource Graph Explorer:
72+
73+
- Azure portal: <a href="https://portal.azure.com/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/SpotResources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fskuspotpricehistory%2Fostype%2Flocation%27%0A%7C%20where%20sku.name%20in~%20%28%27standard_d2s_v4%27%2C%20%27standard_d4s_v4%27%29%0A%7C%20where%20properties.osType%20%3D~%20%27linux%27%0A%7C%20where%20location%20in~%20%28%27eastus%27%2C%20%27southcentralus%27%29%0A%7C%20project%20skuName%20%3D%20tostring%28sku.name%29%2C%20osType%20%3D%20tostring%28properties.osType%29%2C%20location%2C%20latestSpotPriceUSD%20%3D%20todouble%28properties.spotPrices%5B0%5D.priceUSD%29%0A%7C%20order%20by%20latestSpotPriceUSD%20asc" target="_blank">portal.Azure.com</a>
74+
- Azure Government portal: <a href="https://portal.azure.us/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/SpotResources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fskuspotpricehistory%2Fostype%2Flocation%27%0A%7C%20where%20sku.name%20in~%20%28%27standard_d2s_v4%27%2C%20%27standard_d4s_v4%27%29%0A%7C%20where%20properties.osType%20%3D~%20%27linux%27%0A%7C%20where%20location%20in~%20%28%27eastus%27%2C%20%27southcentralus%27%29%0A%7C%20project%20skuName%20%3D%20tostring%28sku.name%29%2C%20osType%20%3D%20tostring%28properties.osType%29%2C%20location%2C%20latestSpotPriceUSD%20%3D%20todouble%28properties.spotPrices%5B0%5D.priceUSD%29%0A%7C%20order%20by%20latestSpotPriceUSD%20asc" target="_blank">portal.Azure.us</a>
75+
- Azure China 21Vianet portal: <a href="https://portal.azure.cn/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/SpotResources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fskuspotpricehistory%2Fostype%2Flocation%27%0A%7C%20where%20sku.name%20in~%20%28%27standard_d2s_v4%27%2C%20%27standard_d4s_v4%27%29%0A%7C%20where%20properties.osType%20%3D~%20%27linux%27%0A%7C%20where%20location%20in~%20%28%27eastus%27%2C%20%27southcentralus%27%29%0A%7C%20project%20skuName%20%3D%20tostring%28sku.name%29%2C%20osType%20%3D%20tostring%28properties.osType%29%2C%20location%2C%20latestSpotPriceUSD%20%3D%20todouble%28properties.spotPrices%5B0%5D.priceUSD%29%0A%7C%20order%20by%20latestSpotPriceUSD%20asc" target="_blank">portal.Azure.cn</a>
76+
77+
---
78+

0 commit comments

Comments
 (0)