Skip to content

Commit c57b1bb

Browse files
authored
Added TimeCreated property to Vm and Vmss models (#19477)
* dev, test, changelog * cleanup
1 parent 75c984a commit c57b1bb

File tree

6 files changed

+4401
-0
lines changed

6 files changed

+4401
-0
lines changed

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,5 +507,12 @@ public void TestVirtualMachineGuestAttestation()
507507
{
508508
TestRunner.RunTestScript("Test-VirtualMachineGuestAttestation");
509509
}
510+
511+
[Fact]
512+
[Trait(Category.AcceptanceType, Category.CheckIn)]
513+
public void TestVMandVMSSTimeCreated()
514+
{
515+
TestRunner.RunTestScript("Test-VMandVMSSTimeCreated");
516+
}
510517
}
511518
}

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5879,3 +5879,57 @@ function Test-VirtualMachineGuestAttestation
58795879
Clean-ResourceGroup $rgname;
58805880
}
58815881
}
5882+
5883+
<#
5884+
.SYNOPSIS
5885+
Test to ensure the TimeCreated property is returned in the VM and VMSS models.
5886+
#>
5887+
function Test-VMandVMSSTimeCreated
5888+
{
5889+
# Setup
5890+
$rgname = Get-ComputeTestResourceName;
5891+
$loc = Get-ComputeVMLocation;
5892+
5893+
try
5894+
{
5895+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
5896+
5897+
# VM Profile & Hardware
5898+
$vnetname = "myVnet";
5899+
$vnetAddress = "10.0.0.0/16";
5900+
$subnetname = "slb" + $rgname;
5901+
$subnetAddress = "10.0.2.0/24";
5902+
$vmssName = "vmss" + $rgname;
5903+
$FaultDomainNumber = 2;
5904+
$vmssFaultDomain = 3;
5905+
5906+
# Creating a new vmss
5907+
$VmSku = "Standard_E2s_v3"
5908+
$domainNameLabel = "d1"+ $rgname;
5909+
$vmssname = "MyVmss"
5910+
$username = "admin01"
5911+
$password = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force
5912+
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
5913+
New-AzVmss -Name $vmssname -ResourceGroup $rgname -Credential $cred -HostGroupId $hostGroup.Id -Zone $zone -VmSize $VmSku -DomainNameLabel $domainNameLabel
5914+
$vmss = Get-AzVmss -ResourceGroupName $rgname -Name $vmssname;
5915+
Assert-NotNull $vmss.TimeCreated;
5916+
5917+
5918+
# Creating a VM using Simple parameterset
5919+
$securePassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
5920+
$user = "admin01";
5921+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
5922+
5923+
# Create VM using Default Parameter set
5924+
$domainNameLabel = "d2" + $rgname;
5925+
$vmname = "vmnam";
5926+
New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel;
5927+
$vm = Get-AzVm -ResourceGroupName $rgname -Name $vmname;
5928+
Assert-NotNull $vm.TimeCreated;
5929+
}
5930+
finally
5931+
{
5932+
# Cleanup
5933+
Clean-ResourceGroup $rgname;
5934+
}
5935+
}

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

Lines changed: 4326 additions & 0 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Added the `TimeCreated` property to the Virtual Machine and Virtual Machine Scale Set models.
2324

2425
## Version 4.31.0
2526
* Added Trusted Launch Generic Breaking Change warning for `New-AzVM`, `New-AzDisk` and `New-AzVMSS` cmdlets.

src/Compute/Compute/Generated/Models/PSVirtualMachineScaleSet.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,11 @@ public string ResourceGroupName
6767
public IDictionary<string, string> Tags { get; set; }
6868
public PSVirtualMachineScaleSetVMProfile VirtualMachineProfile { get; set; }
6969
public string OrchestrationMode { get; set; }
70+
71+
//
72+
// Summary:
73+
// Gets specifies the time at which the Virtual Machine Scale Set resource was created.&lt;br&gt;&lt;br&gt;Minimum
74+
// api-version: 2022-03-01.
75+
public DateTime? TimeCreated { get; private set; }
7076
}
7177
}

src/Compute/Compute/Models/PSVirtualMachine.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Collections.Generic;
2424
using System.Text.RegularExpressions;
2525
using Microsoft.Azure.Commands.Compute.Automation.Models;
26+
using System;
2627

2728
namespace Microsoft.Azure.Commands.Compute.Models
2829
{
@@ -140,5 +141,11 @@ public string ResourceGroupName
140141
public PSApplicationProfile ApplicationProfile { get; set; }
141142

142143
public int? PlatformFaultDomain { get; set; }
144+
145+
//
146+
// Summary:
147+
// Gets specifies the time at which the Virtual Machine resource was created.&lt;br&gt;&lt;br&gt;Minimum
148+
// api-version: 2022-03-01.
149+
public DateTime? TimeCreated { get; private set; }
143150
}
144151
}

0 commit comments

Comments
 (0)