Skip to content

Commit 2dbf8eb

Browse files
Sandidovidai-msft
andauthored
Add dynamic message to user when they use soon to be deprecated Image Alias values (Azure#22007)
* vm and vmss and changelog * clean * removed null check should be fine --------- Co-authored-by: Vincent Dai <[email protected]>
1 parent 63b16d4 commit 2dbf8eb

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Compute/Compute/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* Added new `ResourceId` parameter to the `Get-AzVmss` cmdlet.
2525
* Added `-SecurityType`, `-EnableSecureBoot` and `-EnableVtpm` parameters to `New-AzVm`,`New-AzVmConfig`, `New-AzVmss`, `New-AzVmssConfig`, `Update-AzVm` and `Update-AzVmss` cmdlets.
2626
* Configured parameter flags `-EnableSecureBoot` and `-EnableVtpm` to default to True for TrustedLaunch and ConfidentialVM values for the `-SecurityType` parameter in `New-AzVm`,`New-AzVmConfig`, `New-AzVmss`, `New-AzVmssConfig`, `Update-AzVm` and `Update-AzVmss` cmdlets.
27+
* Added a message to the user when they provide an outdated image alias to `New-AzVM` via the `-Image` parameter or to `New-AzVmss` via the `-ImageName` parameter.
28+
The non-versioned image aliases are being updated to versioned values in October 2023, and this message is to help urge customers to use the newer versioned image alias values.
2729

2830
## Version 6.0.0
2931
* Added new switch parameter `OSImageScheduledEventEnabled` and string parameter `OSImageScheduledEventNotBeforeTimeoutInMinutes` to the cmdlets `New-AzVmssConfig` and `Update-AzVmss`.

src/Compute/Compute/Manual/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ public async Task<ResourceConfig<VirtualMachineScaleSet>> CreateConfigAsync()
299299

300300
private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetNormalMode()
301301
{
302+
// Temporary message until after the Ignite 2023 release that should remove these outdated image aliases.
303+
if ((_cmdlet.ImageName == "CentOS" || _cmdlet.ImageName == "Debian" || _cmdlet.ImageName == "RHEL"
304+
|| _cmdlet.ImageName == "UbuntuLTS"))
305+
{
306+
string ImageOutdatedMessage = "You are using the image " + _cmdlet.ImageName + ", which is outdated and this image name will be removed in October 2023. Please update to a newer versioned image alias as seen here, [Find and use Azure Marketplace VM images with Azure PowerShell](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage#default-images).";
307+
_cmdlet.WriteInformation(ImageOutdatedMessage, new string[] { "PSHOST" });
308+
}
309+
302310
ImageAndOsType = await _client.UpdateImageAndOsTypeAsync(
303311
ImageAndOsType, _cmdlet.ResourceGroupName, _cmdlet.ImageName, Location);
304312

@@ -488,6 +496,14 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrc
488496
int platformFaultDomainCountFlexibleDefault = 1;
489497
SwitchParameter singlePlacementGroupFlexibleDefault = false;
490498

499+
// Temporary message until after the Ignite 2023 release that should remove these outdated image aliases.
500+
if ((_cmdlet.ImageName == "CentOS" || _cmdlet.ImageName == "Debian" || _cmdlet.ImageName == "RHEL"
501+
|| _cmdlet.ImageName == "UbuntuLTS"))
502+
{
503+
string ImageOutdatedMessage = "You are using the image " + _cmdlet.ImageName + ", which is outdated and this image name will be removed in October 2023. Please update to a newer versioned image alias as seen here, [Find and use Azure Marketplace VM images with Azure PowerShell](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage#default-images).";
504+
_cmdlet.WriteInformation(ImageOutdatedMessage, new string[] { "PSHOST" });
505+
}
506+
491507
ImageAndOsType = await _client.UpdateImageAndOsTypeAsync(
492508
ImageAndOsType, _cmdlet.ResourceGroupName, _cmdlet.ImageName, Location);
493509

src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,14 @@ public async Task<ResourceConfig<VirtualMachine>> CreateConfigAsync()
535535

536536
if (_cmdlet.DiskFile == null)
537537
{
538+
// Temporary message until after the Ignite 2023 release that should remove these outdated image aliases.
539+
if ((_cmdlet.Image == "CentOS" || _cmdlet.Image == "Debian" || _cmdlet.Image == "RHEL"
540+
|| _cmdlet.Image == "UbuntuLTS"))
541+
{
542+
string ImageOutdatedMessage = "You are using the image " + _cmdlet.Image + ", which is outdated and this image name will be removed in October 2023. Please update to a newer versioned image alias as seen here, [Find and use Azure Marketplace VM images with Azure PowerShell](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage#default-images).";
543+
_cmdlet.WriteInformation(ImageOutdatedMessage, new string[] { "PSHOST" });
544+
}
545+
538546
ImageAndOsType = await _client.UpdateImageAndOsTypeAsync(
539547
ImageAndOsType, _cmdlet.ResourceGroupName, _cmdlet.Image, Location);
540548
}

0 commit comments

Comments
 (0)