Skip to content

Commit dc8f4d0

Browse files
committed
Update filter expression for Get-AzureVMImage and Get-AzureVMExtensionImage cmdlets
1 parent b999f76 commit dc8f4d0

File tree

8 files changed

+1556
-1678
lines changed

8 files changed

+1556
-1678
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.Management.Compute">
7070
<SpecificVersion>False</SpecificVersion>
71-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.0.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
71+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.1.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
7272
<Private>True</Private>
7373
</Reference>
7474
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -98,7 +98,7 @@
9898
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
9999
</Reference>
100100
<Reference Include="Microsoft.Rest.ClientRuntime">
101-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.4.1\lib\dotnet\Microsoft.Rest.ClientRuntime.dll</HintPath>
101+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.8.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
102102
<Private>True</Private>
103103
</Reference>
104104
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.ps1

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ function Test-VirtualMachineList
400400
Assert-NotNull $s2[0].Id;
401401
}
402402

403-
Assert-ThrowsContains { $s3 = Get-AzureRmVM -NextLink "http://www.test.com/test"; } "Unexpected character"
403+
Assert-ThrowsContains { $s3 = Get-AzureRmVM -NextLink "http://www.test.com/test"; } "Unable to deserialize the response"
404404

405405
$passed = $true;
406406
}
@@ -455,20 +455,15 @@ function Test-VirtualMachineImageList
455455
{
456456
$versions = $s4 | select -ExpandProperty Version;
457457

458-
$s5 = Get-AzureRmVMImage -Location $locStr -PublisherName $pub -Offer $offer -Sku $sku -FilterExpression ('name -eq *');
459-
Assert-NotNull $s5;
460-
Assert-NotNull $s5.Count -gt 0;
461-
$verNames = $s5 | select -ExpandProperty Version;
462-
463458
foreach ($ver in $versions)
464459
{
465460
if ($ver -eq $null -or $ver -eq '') { continue; }
466461
$s6 = Get-AzureRmVMImage -Location $locStr -PublisherName $pub -Offer $offer -Sku $sku -Version $ver;
467462
Assert-NotNull $s6;
468463
$s6;
469464

470-
Assert-True { $verNames -contains $ver };
471-
Assert-True { $verNames -contains $s6.Name };
465+
Assert-True { $versions -contains $ver };
466+
Assert-True { $versions -contains $s6.Name };
472467

473468
$s6.Id;
474469

@@ -498,15 +493,14 @@ function Test-VirtualMachineImageList
498493
{
499494
foreach ($type in $types)
500495
{
501-
$s2 = Get-AzureRmVMExtensionImage -Location $locStr -PublisherName $pub -Type $type -FilterExpression '*';
496+
$s2 = Get-AzureRmVMExtensionImage -Location $locStr -PublisherName $pub -Type $type -FilterExpression "startswith(name,'1')";
502497
$versions = $s2 | select -ExpandProperty Version;
503498
foreach ($ver in $versions)
504499
{
505-
$s3 = Get-AzureRmVMExtensionImage -Location $locStr -PublisherName $pub -Type $type -Version $ver -FilterExpression '*';
500+
$s3 = Get-AzureRmVMExtensionImage -Location $locStr -PublisherName $pub -Type $type -Version $ver;
506501

507502
Assert-NotNull $s3;
508503
Assert-True { $s3.Version -eq $ver; }
509-
510504
$s3.Id;
511505

512506
$foundAnyExtensionImage = $true;

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVirtualMachineImageList.json

Lines changed: 1532 additions & 1648 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
10-
<package id="Microsoft.Azure.Management.Compute" version="11.0.0-prerelease" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.Compute" version="11.1.0-prerelease" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
@@ -17,7 +17,7 @@
1717
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
1818
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.18.206251556" targetFramework="net45" />
1919
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
20-
<package id="Microsoft.Rest.ClientRuntime" version="1.4.1" targetFramework="net45" />
20+
<package id="Microsoft.Rest.ClientRuntime" version="1.8.2" targetFramework="net45" />
2121
<package id="Microsoft.Rest.ClientRuntime.Azure" version="2.1.0" targetFramework="net45" />
2222
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="0.11.0" targetFramework="net45" />
2323
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.0.0-preview" targetFramework="net45" />

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</Reference>
8383
<Reference Include="Microsoft.Azure.Management.Compute">
8484
<SpecificVersion>False</SpecificVersion>
85-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.0.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
85+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.1.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
8686
<Private>True</Private>
8787
</Reference>
8888
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -113,17 +113,13 @@
113113
<Private>True</Private>
114114
</Reference>
115115
<Reference Include="Microsoft.Rest.ClientRuntime">
116-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.4.1\lib\dotnet\Microsoft.Rest.ClientRuntime.dll</HintPath>
116+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.8.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
117117
<Private>True</Private>
118118
</Reference>
119119
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
120120
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\dotnet\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
121121
<Private>True</Private>
122122
</Reference>
123-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
124-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\portable-net45+win8+wpa81\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
125-
<Private>True</Private>
126-
</Reference>
127123
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
128124
<SpecificVersion>False</SpecificVersion>
129125
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
@@ -385,6 +381,7 @@
385381
</None>
386382
<None Include="Microsoft.Azure.Commands.Compute.format.ps1xml">
387383
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
384+
<SubType>Designer</SubType>
388385
</None>
389386
<Content Include="Microsoft.Azure.Commands.Compute.Types.ps1xml">
390387
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

src/ResourceManager/Compute/Commands.Compute/ExtensionImages/GetAzureVMExtensionImageCommand.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Management.Compute.Models;
18+
using Microsoft.Rest.Azure.OData;
1719
using System.Linq;
1820
using System.Management.Automation;
1921

@@ -47,12 +49,13 @@ public override void ExecuteCmdlet()
4749
{
4850
if (string.IsNullOrEmpty(this.Version))
4951
{
52+
var filter = new ODataQuery<VirtualMachineImageResource>(this.FilterExpression);
53+
5054
var result = this.VirtualMachineExtensionImageClient.ListVersionsWithHttpMessagesAsync(
5155
this.Location.Canonicalize(),
5256
this.PublisherName,
5357
this.Type,
54-
//this.FilterExpression).GetAwaiter().GetResult();
55-
null).GetAwaiter().GetResult(); // Bug:
58+
odataQuery: filter).GetAwaiter().GetResult();
5659

5760
var images = from r in result.Body
5861
select new PSVirtualMachineExtensionImage

src/ResourceManager/Compute/Commands.Compute/Images/GetAzureVMImageCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
1717
using Microsoft.Azure.Management.Compute.Models;
18-
using System.Collections.Generic;
18+
using Microsoft.Rest.Azure.OData;
1919
using System.Linq;
2020
using System.Management.Automation;
21-
using Microsoft.Rest.Azure;
2221

2322
namespace Microsoft.Azure.Commands.Compute
2423
{
@@ -88,13 +87,14 @@ public override void ExecuteCmdlet()
8887
{
8988
if (this.ParameterSetName.Equals(ListVMImageParamSetName))
9089
{
90+
var filter = new ODataQuery<VirtualMachineImageResource>(this.FilterExpression);
91+
9192
var result = this.VirtualMachineImageClient.ListWithHttpMessagesAsync(
9293
this.Location.Canonicalize(),
9394
this.PublisherName,
9495
this.Offer,
9596
this.Skus,
96-
//this.FilterExpression).GetAwaiter().GetResult();
97-
null).GetAwaiter().GetResult(); // BUG: ODataUriParser.ParseFilter
97+
odataQuery: filter).GetAwaiter().GetResult();
9898

9999
var images = from r in result.Body
100100
select new PSVirtualMachineImage
@@ -119,7 +119,7 @@ public override void ExecuteCmdlet()
119119
this.PublisherName,
120120
this.Offer,
121121
this.Skus,
122-
this.Version).GetAwaiter().GetResult();
122+
version: this.Version).GetAwaiter().GetResult();
123123

124124
var image = new PSVirtualMachineImageDetail
125125
{

src/ResourceManager/Compute/Commands.Compute/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
12-
<package id="Microsoft.Azure.Management.Compute" version="11.0.0-prerelease" targetFramework="net45" />
12+
<package id="Microsoft.Azure.Management.Compute" version="11.1.0-prerelease" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
1515
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
@@ -20,7 +20,7 @@
2020
<package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net45" />
2121
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.18.206251556" targetFramework="net45" />
2222
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
23-
<package id="Microsoft.Rest.ClientRuntime" version="1.4.1" targetFramework="net45" />
23+
<package id="Microsoft.Rest.ClientRuntime" version="1.8.2" targetFramework="net45" />
2424
<package id="Microsoft.Rest.ClientRuntime.Azure" version="2.1.0" targetFramework="net45" />
2525
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="0.11.0" targetFramework="net45" />
2626
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />

0 commit comments

Comments
 (0)