Azure / Azure/azure-devtestlab

How to update/extend expirationDate of an existing DevTest lab VM that already has one set?

Open
#776 2 comments 0 reactions 0 assignees View on GitHub
az.devtestlabs question
Dominant language
PowerShell
Stars
465
Forks
595
PR merge metrics
No merged PRs in 30d

Description

Hi,

Searching the internet we found some articles regarding how to use Azure PowerShell to extend a date on a lab VM for expiry.

Examples:
1. https://github.com/Azure-Samples/virtual-machines-powershell-auto-expired/blob/master/README.md
2. https://social.msdn.microsoft.com/Forums/azure/en-US/72034bf9-37c9-464e-8c2f-2ca9b9424a4c/how-to-change-or-postpone-a-vm-expiration-datetime-?forum=AzureDevTestLabs
3. https://feedback.azure.com/forums/320373-lab-services/suggestions/34793482-postpone-expiration-date-for-individual-vms-if-nee
4. https://azure.microsoft.com/en-gb/blog/set-expiration-date-for-vms-in-azure-devtest-labs/
etc.

So, a lab user created a VM with 24 hr expiry and now wishes to keep it longer due to testing which has not concluded.
Whatever we try we just get the following error back on the ```Set-AzureRmResource``` command:

```Set-AzureRmResource : MissingRequiredProperties : One of the following properties must be specified: customImageId, galleryImageReference.```

Note our lab VM is created from an ARM template and from a lab attached shared image gallery (so a custom image in our private shared image gallery, not a public/marketplace image). As it's a private shared image gallery, it's not a true lab custom image either as such. So, in our ARM template we do not provide gallery reference or custom image ID, but more SharedImageID and SharedImageVersion.

We have tried to provide null values, or what we think may be suitable values for the "missing" properties but then we get error ```Set-AzureRmResource : CannotSetProperty : Cannot set or update property galleryImageReference.``` or ```Set-AzureRmResource : CannotSetProperty : Cannot set or update property customImageId.```

Using AzureRm 6.13.1 but also tried Az in pwsh core and same issue.

Note that we get this error if we just get the VM object (using ```Get-AzureRmResource```) change no properties and then set it back using ```Set-AzureRmResource```.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.