Skip to content

Get-AzVMImage list to return additional properties #27617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f7964b0
md files
grizzlytheodore Mar 23, 2025
a99ae26
code changes
grizzlytheodore Mar 23, 2025
c4ae378
generated with new API version
grizzlytheodore Mar 25, 2025
6ea7925
fix typo
grizzlytheodore Mar 25, 2025
1496273
changelog
grizzlytheodore Mar 25, 2025
4ba7d4c
test added
grizzlytheodore Mar 25, 2025
b4e883f
Merge branch 'main' into feature/cplat-PlacementFeature
grizzlytheodore Mar 25, 2025
dd6cdf8
Update VirtualMachineStrategy.cs
grizzlytheodore Mar 25, 2025
43f571f
Update VirtualMachineStrategy.cs
grizzlytheodore Mar 25, 2025
bd832eb
update sku for maintenance New-VirtualMachine test
grizzlytheodore Mar 26, 2025
db668d7
Merge branch 'feature/cplat-PlacementFeature' of https://github.com/A…
grizzlytheodore Mar 26, 2025
3e57b7d
example static analysis undo
grizzlytheodore Mar 26, 2025
d9bf4e8
undo changes to maintenance files
grizzlytheodore Mar 26, 2025
1bf42d1
undo maintenance change
grizzlytheodore Mar 26, 2025
181c659
Remove compute sdk from maintenance test (#27454)
VeryEarly Mar 27, 2025
5c8855a
fix swagger and properties capitalization
grizzlytheodore Apr 14, 2025
8aa2a0a
generated with enum as expand
grizzlytheodore Apr 15, 2025
cf28168
saved changes
grizzlytheodore Apr 21, 2025
322925d
merge comflict
grizzlytheodore May 7, 2025
b9c7820
change log and output for mat
grizzlytheodore May 7, 2025
ab553c4
tests added
grizzlytheodore May 7, 2025
8cf2412
tests added
grizzlytheodore May 7, 2025
e913a38
fixed
grizzlytheodore May 7, 2025
299db6f
update failing test
grizzlytheodore May 8, 2025
709ae81
fix failing test
grizzlytheodore May 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ public partial interface IVirtualMachineImagesOperations
/// <param name='skus'>
/// A valid image SKU.
/// </param>
/// <param name='expand'>
/// The expand expression to apply on the operation.
/// </param>
/// <param name='top'>
/// </param>
/// <param name='orderby'>
Expand All @@ -231,7 +234,7 @@ public partial interface IVirtualMachineImagesOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<IPage<VirtualMachineImage>>> ListWithPropertiesWithHttpMessagesAsync(string location, string publisherName, string offer, string skus, int? top = default(int?), string orderby = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<AzureOperationResponse<IList<VirtualMachineImage>>> ListWithPropertiesWithHttpMessagesAsync(string location, string publisherName, string offer, string skus, string expand, int? top = default(int?), string orderby = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <param name='nextPageLink'>
/// The NextLink from the previous successful call to List operation.
/// </param>
Expand All @@ -250,6 +253,6 @@ public partial interface IVirtualMachineImagesOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<IPage<VirtualMachineImage>>> ListWithPropertiesNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<AzureOperationResponse<IList<VirtualMachineImage>>> ListWithPropertiesNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,9 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
/// <param name='skus'>
/// A valid image SKU.
/// </param>
/// <param name='expand'>
/// The expand expression to apply on the operation.
/// </param>
/// <param name='top'>
/// </param>
/// <param name='orderby'>
Expand All @@ -1323,7 +1326,7 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IPage<VirtualMachineImage>>> ListWithPropertiesWithHttpMessagesAsync(string location, string publisherName, string offer, string skus, int? top = default(int?), string orderby = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<IList<VirtualMachineImage>>> ListWithPropertiesWithHttpMessagesAsync(string location, string publisherName, string offer, string skus, string expand, int? top = default(int?), string orderby = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (location == null)
{
Expand All @@ -1341,11 +1344,14 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
{
throw new ValidationException(ValidationRules.CannotBeNull, "skus");
}
if (expand == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "expand");
}
if (Client.SubscriptionId == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
}
string expand = "Properties";
string apiVersion = "2024-11-01";
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
Expand Down Expand Up @@ -1483,7 +1489,7 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
throw ex;
}
// Create Result
var _result = new AzureOperationResponse<IPage<VirtualMachineImage>>();
var _result = new AzureOperationResponse<IList<VirtualMachineImage>>();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
Expand All @@ -1496,7 +1502,7 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<VirtualMachineImage>>(_responseContent, Client.DeserializationSettings);
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<VirtualMachineImage>>(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
Expand Down Expand Up @@ -1539,7 +1545,7 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IPage<VirtualMachineImage>>> ListWithPropertiesNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<IList<VirtualMachineImage>>> ListWithPropertiesNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (nextPageLink == null)
{
Expand Down Expand Up @@ -1653,7 +1659,7 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
throw ex;
}
// Create Result
var _result = new AzureOperationResponse<IPage<VirtualMachineImage>>();
var _result = new AzureOperationResponse<IList<VirtualMachineImage>>();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
Expand All @@ -1666,7 +1672,7 @@ internal VirtualMachineImagesOperations(ComputeManagementClient client)
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<VirtualMachineImage>>(_responseContent, Client.DeserializationSettings);
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<VirtualMachineImage>>(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,16 @@ public static VmImagesInEdgeZoneListResult ListByEdgeZone(this IVirtualMachineIm
/// <param name='skus'>
/// A valid image SKU.
/// </param>
/// <param name='expand'>
/// The expand expression to apply on the operation.
/// </param>
/// <param name='top'>
/// </param>
/// <param name='orderby'>
/// </param>
public static IPage<VirtualMachineImage> ListWithProperties(this IVirtualMachineImagesOperations operations, string location, string publisherName, string offer, string skus, int? top = default(int?), string orderby = default(string))
public static IList<VirtualMachineImage> ListWithProperties(this IVirtualMachineImagesOperations operations, string location, string publisherName, string offer, string skus, string expand, int? top = default(int?), string orderby = default(string))
{
return operations.ListWithPropertiesAsync(location, publisherName, offer, skus, top, orderby).GetAwaiter().GetResult();
return operations.ListWithPropertiesAsync(location, publisherName, offer, skus, expand, top, orderby).GetAwaiter().GetResult();
}

/// <param name='operations'>
Expand All @@ -356,16 +359,19 @@ public static VmImagesInEdgeZoneListResult ListByEdgeZone(this IVirtualMachineIm
/// <param name='skus'>
/// A valid image SKU.
/// </param>
/// <param name='expand'>
/// The expand expression to apply on the operation.
/// </param>
/// <param name='top'>
/// </param>
/// <param name='orderby'>
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IPage<VirtualMachineImage>> ListWithPropertiesAsync(this IVirtualMachineImagesOperations operations, string location, string publisherName, string offer, string skus, int? top = default(int?), string orderby = default(string), CancellationToken cancellationToken = default(CancellationToken))
public static async Task<IList<VirtualMachineImage>> ListWithPropertiesAsync(this IVirtualMachineImagesOperations operations, string location, string publisherName, string offer, string skus, string expand, int? top = default(int?), string orderby = default(string), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ListWithPropertiesWithHttpMessagesAsync(location, publisherName, offer, skus, top, orderby, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.ListWithPropertiesWithHttpMessagesAsync(location, publisherName, offer, skus, expand, top, orderby, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand All @@ -377,7 +383,7 @@ public static VmImagesInEdgeZoneListResult ListByEdgeZone(this IVirtualMachineIm
/// <param name='nextPageLink'>
/// The NextLink from the previous successful call to List operation.
/// </param>
public static IPage<VirtualMachineImage> ListWithPropertiesNext(this IVirtualMachineImagesOperations operations, string nextPageLink)
public static IList<VirtualMachineImage> ListWithPropertiesNext(this IVirtualMachineImagesOperations operations, string nextPageLink)
{
return operations.ListWithPropertiesNextAsync(nextPageLink).GetAwaiter().GetResult();
}
Expand All @@ -391,7 +397,7 @@ public static IPage<VirtualMachineImage> ListWithPropertiesNext(this IVirtualMac
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IPage<VirtualMachineImage>> ListWithPropertiesNextAsync(this IVirtualMachineImagesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<IList<VirtualMachineImage>> ListWithPropertiesNextAsync(this IVirtualMachineImagesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ListWithPropertiesNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Compute.Management.Sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ directive:

###
``` yaml
commit: 8e064cb38f22bc60d94ce8ec2c987aa04dbc618e
commit: e2bdeadfb399be0691fb9d0425bd2b32d252538c
input-file:
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/compute/resource-manager/Microsoft.Compute/common-types/v1/common.json
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-11-01/computeRPCommon.json
Expand Down
14 changes: 10 additions & 4 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,8 @@ function Test-VMImageCmdletOutputFormat

Assert-OutputContains " Get-AzVMImagePublisher -Location '$locStr' | ? { `$_.PublisherName -eq `'$publisher`' } | Get-AzVMImageOffer | Get-AzVMImageSku " @('Publisher', 'Offer', 'Skus');

Assert-OutputContains " Get-AzVMImagePublisher -Location '$locStr' | ? { `$_.PublisherName -eq `'$publisher`' } | Get-AzVMImageOffer | Get-AzVMImageSku | Get-AzVMImage " @('Version', 'Skus');
# Updated Get-AzVmImage list output. No need to output sku when user inputed that. There are more valuable information to display.
Assert-OutputContains " Get-AzVMImagePublisher -Location '$locStr' | ? { `$_.PublisherName -eq `'$publisher`' } | Get-AzVMImageOffer | Get-AzVMImageSku | Get-AzVMImage " @('Version', 'Location');

Assert-OutputContains " Get-AzVMImage -Location '$locStr' -PublisherName $publisher -Offer $offer -Skus $sku -Version $ver " @('Id', 'Location', 'PublisherName', 'Offer', 'Sku', 'Version', 'Name', 'DataDiskImages', 'OSDiskImage', 'PurchasePlan');

Expand All @@ -2162,7 +2163,7 @@ function Test-VMImageEdgeZoneCmdletOutputFormat

Assert-OutputContains " Get-AzVMImagePublisher -Location '$locStr' | ? { `$_.PublisherName -eq `'$publisher`' } | Get-AzVMImageOffer -EdgeZone '$edgeZone'| Get-AzVMImageSku " @('Publisher', 'Offer', 'Skus');

Assert-OutputContains " Get-AzVMImagePublisher -Location '$locStr' | ? { `$_.PublisherName -eq `'$publisher`' } | Get-AzVMImageOffer -EdgeZone '$edgeZone' | Get-AzVMImageSku | Get-AzVMImage " @('Version', 'Skus');
Assert-OutputContains " Get-AzVMImagePublisher -Location '$locStr' | ? { `$_.PublisherName -eq `'$publisher`' } | Get-AzVMImageOffer -EdgeZone '$edgeZone' | Get-AzVMImageSku | Get-AzVMImage " @('Version', 'Location');

Assert-OutputContains " Get-AzVMImage -Location '$locStr' -EdgeZone '$edgeZone' -PublisherName $publisher -Offer $offer -Skus $sku -Version $ver " @('Id', 'Location', 'PublisherName', 'Offer', 'Sku', 'Version', 'Name', 'DataDiskImages', 'OSDiskImage', 'PurchasePlan');

Expand Down Expand Up @@ -4850,14 +4851,19 @@ function Test-VirtualMachineImageListTopOrderExpand
$pubNames = "MicrosoftWindowsServer";
$pubNameFilter = '*Windows*';
$offer = "windowsserver";
$sku = "2012-R2-Datacenter";
$sku = "2025-datacenter";
$numRecords = 3;
$orderNameDesc = "name desc";
$orderNameAsc = "name asc";

# Test -Top
$vmImagesTop = Get-AzVMImage -Location $loc -PublisherName $pubNames -Offer $offer -Sku $sku -Top $numRecords;
$vmImagesTop = Get-AzVMImage -Location $loc -PublisherName $pubNames -Offer $offer -Sku $sku -Top $numRecords -Expand "properties";
Assert-AreEqual $numRecords $vmImagesTop.Count;
Assert-NotNull $vmImagesTop[0].Architecture;
Assert-NotNull $vmImagesTop[0].HyperVGeneration;

$vmImagesTop = Get-AzVMImage -Location $loc -PublisherName $pubNames -Offer $offer -Sku $sku -Top $numRecords -Expand "properties/imageDeprecationStatus"
Assert-NotNull $vmImagesTop[0].ImageDeprecationStatus

# Test -OrderBy
$vmImagesOrderDesc = Get-AzVMImage -Location $loc -PublisherName $pubNames -Offer $offer -Sku $sku -OrderBy $orderNameDesc;
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

-->
## Upcoming Release
* Added new properties `Architecture`, `HyperVGeneration`, and `ImageDeprecationStatus` to be returned in `Get-AzVMImage` ListVMImage parameter set.
* Deprecated `Get-AzVMSize` 'List Virtual Machine Size' parameter set.
* Added new parameters `EnableAutomaticZoneRebalance`, `AutomaticZoneRebalanceStrategy` and `AutomaticZoneRebalanceBehavior` to `New-AzVmssConfig` and `Update-AzVmss` cmdlets for VMSS Automatic Zone Rebalancing.

Expand Down
10 changes: 5 additions & 5 deletions src/Compute/Compute/Compute.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,19 @@
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Skus</PropertyName>
<PropertyName>Location</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Offer</PropertyName>
<PropertyName>PublisherName</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>PublisherName</PropertyName>
<PropertyName>HyperVGeneration</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Location</PropertyName>
<PropertyName>Architecture</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Id</PropertyName>
<PropertyName>ImageDeprecationStatus</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
Expand Down
Loading
Loading