Skip to content

Commit d6bf06b

Browse files
grizzlytheodoreVeryEarlywyunchi-ms
authored
adding -Location parameter to get-azComputeResourceSku (#12408)
* adding warning when not using latest image version when creading vmss * update to tabified file * add missing bracket * remove new lines from Get-Content call * minor fixes * using assert-true method * removing some commmented out code * align * indent * newline at the end * Update ChangeLog.md * add location parameter to get-azcomputeresourcesku * add help file * update changelog.md * review update * Update ChangeLog.md * review fixes * test commit * undo test Co-authored-by: Yabo Hu <yabhu@microsoft.com> Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com>
1 parent f532b9b commit d6bf06b

File tree

6 files changed

+122
-5
lines changed

6 files changed

+122
-5
lines changed

src/Compute/Compute.Test/ScenarioTests/ResourceSkuTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@ public void TestGetResourceSku()
3030
{
3131
TestRunner.RunTestScript("Test-GetResourceSku");
3232
}
33+
34+
[Fact]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
36+
public void TestGetResourceSkuByLocation()
37+
{
38+
TestRunner.RunTestScript("Test-GetResourceSkuByLocation");
39+
}
3340
}
3441
}

src/Compute/Compute.Test/ScenarioTests/ResourceSkuTests.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ function Test-GetResourceSku
2525
Assert-True { $output.Contains("virtualMachines"); }
2626
Assert-True { $output.Contains("Zones"); }
2727
}
28+
29+
<#
30+
.SYNOPSIS
31+
Test List Resource Skus by Location
32+
#>
33+
function Test-GetResourceSkuByLocation
34+
{
35+
$skulist = Get-AzComputeResourceSku "westus" | where {$_.Locations -eq "eastus"};
36+
Assert-True { $skulist.Count -eq 0; }
37+
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.ResourceSkuTests/TestGetResourceSkuByLocation.json

Lines changed: 68 additions & 0 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
## Version 4.2.1
2424
* Added warning when using `New-AzVmss` without "latest" image version
25+
* Added '-Location' as optional positional parameter to Get-AzComputeResourceSku cmdlet
2526

2627
## Version 4.2.0
2728
* Added SimulateEviction parameter to Set-AzVM and Set-AzVmssVM cmdlets.

src/Compute/Compute/Generated/ResourceSku/ResourceSkuListMethod.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,29 @@ namespace Microsoft.Azure.Commands.Compute.Automation
3636
[OutputType(typeof(PSResourceSku))]
3737
public partial class GetAzureRmComputeResourceSku : ComputeAutomationBaseCmdlet
3838
{
39+
[Parameter(
40+
Mandatory = false,
41+
Position = 0,
42+
ValueFromPipelineByPropertyName = true)]
43+
[ValidateNotNullOrEmpty]
44+
[LocationCompleter("Microsoft.Compute/locations/publishers")]
45+
public string Location { get; set; }
46+
3947
public override void ExecuteCmdlet()
4048
{
4149
base.ExecuteCmdlet();
4250
ExecuteClientAction(() =>
4351
{
44-
45-
var result = ResourceSkusClient.List();
52+
Microsoft.Rest.Azure.IPage<ResourceSku> result;
53+
if (this.IsParameterBound(c => c.Location))
54+
{
55+
string filter = String.Format("location eq '{0}'", this.Location);
56+
result = ResourceSkusClient.List(filter);
57+
}
58+
else
59+
{
60+
result = ResourceSkusClient.List();
61+
}
4662
var resultList = result.ToList();
4763
var nextPageLink = result.NextPageLink;
4864
while (!string.IsNullOrEmpty(nextPageLink))

src/Compute/Compute/help/Get-AzComputeResourceSku.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ List all compute resource Skus
1313
## SYNTAX
1414

1515
```
16-
Get-AzComputeResourceSku [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
16+
Get-AzComputeResourceSku [[-Location] <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1717
```
1818

1919
## DESCRIPTION
@@ -23,7 +23,7 @@ List all compute resource Skus
2323

2424
### Example 1
2525
```
26-
PS C:\> PS C:\> Get-AzComputeResourceSku | where {$_.Locations.Contains("westus")};
26+
PS C:\> Get-AzComputeResourceSku "westus";
2727
```
2828

2929
List all compute resource skus in West US region
@@ -45,12 +45,27 @@ Accept pipeline input: False
4545
Accept wildcard characters: False
4646
```
4747
48+
### -Location
49+
Specifies a location of the available skus to list.
50+
51+
```yaml
52+
Type: System.String
53+
Parameter Sets: (All)
54+
Aliases:
55+
56+
Required: False
57+
Position: 0
58+
Default value: None
59+
Accept pipeline input: True (ByPropertyName)
60+
Accept wildcard characters: False
61+
```
62+
4863
### CommonParameters
4964
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
5065
5166
## INPUTS
5267
53-
### None
68+
### System.String
5469
5570
## OUTPUTS
5671

0 commit comments

Comments
 (0)