From 6de23b663d79aa70eb101890b3d752a164573c1a Mon Sep 17 00:00:00 2001 From: Theodore Chang Date: Sun, 11 Aug 2024 22:45:19 -0400 Subject: [PATCH] Added information on how to find VM Images when using New-AzVM with -Image parameter. (#25779) * write information when -image is used * change --------- Co-authored-by: Theodore Chang Co-authored-by: Xiaogang --- src/Compute/Compute/ChangeLog.md | 1 + src/Compute/Compute/Common/ConstantStringTypes.cs | 1 + .../Compute/VirtualMachine/Operation/NewAzureVMCommand.cs | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index 96b58de1c324..908a17435bed 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -20,6 +20,7 @@ --> ## Upcoming Release +* Added information on how to find VM Images when using `New-AzVM` with `-Image` parameter. * Added `TimeCreated` read-only field to `PSVirtualMachineScaleSetVMProfile` object. * Added parameter `-ResourceIdsOnly` to `Get-AzCapacityReservationGroup` cmdlet. * Changed the `Set-AzVMOperatingSystem` cmdlet when the `-VM` parameter is used without an OSProfile. Now it will not throw a null reference exception when `-Credential` is not provided. diff --git a/src/Compute/Compute/Common/ConstantStringTypes.cs b/src/Compute/Compute/Common/ConstantStringTypes.cs index d9ee82c66681..58bb18b16347 100644 --- a/src/Compute/Compute/Common/ConstantStringTypes.cs +++ b/src/Compute/Compute/Common/ConstantStringTypes.cs @@ -71,6 +71,7 @@ public static class HelpMessages public const string VMPlanPublisher = "The publisher ID"; public const string TrustedLaunchUpgradeMessage = "Consider upgrading security for your workloads using Azure Trusted Launch VMs. To know more about Trusted Launch, please visit https://aka.ms/TrustedLaunch"; + public const string PSVMImageMessage = "You can reference https://aka.ms/findImagePS on how to find VM Images using PowerShell."; } public static class ValidateSetValues diff --git a/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs b/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs index f69ef24673e6..04aa6d8e3e76 100644 --- a/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs +++ b/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs @@ -770,6 +770,11 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet) PublicIpAddressName = PublicIpAddressName; SecurityGroupName = SecurityGroupName ?? Name; + if (this.IsParameterBound(c => c.Image)) + { + WriteInformation(HelpMessages.PSVMImageMessage, new string[] { "PSHOST" }); + } + // Check TrustedLaunch UEFI values defaulting if (this.IsParameterBound(c => c.SecurityType) && this.SecurityType != null)