Skip to content

Commit 9806a3e

Browse files
Merge pull request #192634 from timwarner-msft/timwarner-bycat
Add sample CLI and PS code to Azure Spot examples
2 parents 116152e + 7edbf12 commit 9806a3e

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

includes/resource-graph/samples/bycat/azure-spot.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: timwarner-msft
33
ms.service: resource-graph
44
ms.topic: include
5-
ms.date: 03/18/2022
5+
ms.date: 03/23/2022
66
ms.author: timwarner
77
ms.custom: generated
88
---
@@ -20,6 +20,28 @@ SpotResources
2020
| order by skuName asc, location asc
2121
```
2222

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+
---
44+
2345
### Compare the latest Spot price across multiple VM SKUs and regions for an OS type
2446

2547
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.
@@ -34,4 +56,25 @@ SpotResources
3456
| order by latestSpotPriceUSD asc
3557
```
3658

59+
# [Azure CLI](#tab/azure-cli)
60+
61+
```azurecli
62+
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"
63+
```
64+
65+
# [Azure PowerShell](#tab/azure-powershell)
66+
67+
```azurepowershell
68+
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"
69+
```
70+
71+
# [Portal](#tab/azure-portal)
72+
73+
:::image type="icon" source="../../../../articles/governance/resource-graph/media/resource-graph-small.png"::: Try this query in Azure Resource Graph Explorer:
74+
75+
- 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>
76+
- 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>
77+
- 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>
78+
3779
---
80+

0 commit comments

Comments
 (0)