diff --git a/src/Compute/Compute.Test/ScenarioTests/PPGTests.cs b/src/Compute/Compute.Test/ScenarioTests/PPGTests.cs index 371c53013006..f0997eaccbfc 100644 --- a/src/Compute/Compute.Test/ScenarioTests/PPGTests.cs +++ b/src/Compute/Compute.Test/ScenarioTests/PPGTests.cs @@ -52,5 +52,12 @@ public void TestPPGVMIntentListAndZones() { TestRunner.RunTestScript("Test-PPGVMIntentAndZoneFeatures"); } - } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgenupdateazavailabilityset() + { + TestRunner.RunTestScript("TestGen-updateazavailabilityset"); + } + } } diff --git a/src/Compute/Compute.Test/ScenarioTests/PPGTests.ps1 b/src/Compute/Compute.Test/ScenarioTests/PPGTests.ps1 index a34c02a45615..ee84c86aa551 100644 --- a/src/Compute/Compute.Test/ScenarioTests/PPGTests.ps1 +++ b/src/Compute/Compute.Test/ScenarioTests/PPGTests.ps1 @@ -429,3 +429,48 @@ function Test-PPGVMIntentAndZoneFeatures Clean-ResourceGroup $rgname; } } + +function TestGen-updateazavailabilityset +{ + param ($loc) + # Setup + $rgname = Get-ComputeTestResourceName + + try + { + # Common + [string]$loc = Get-Location; + $loc = $loc.Replace(' ', ''); + + New-AzResourceGroup -Name $rgname -Location $loc -Force; + + # Create an Availability Set + $avSetName = $rgname + 'avset' + $availabilitySet = New-AzAvailabilitySet -ResourceGroupName $rgname -Name $avSetName -Location $loc -Sku Aligned + + # Update the Availability Set with new parameters + Update-AzAvailabilitySet -ResourceGroupName $rgname -Name $avSetName ` + -ScheduledEventsAdditionalEndpoints $true ` + -EnableUserRebootScheduledEvents $true ` + -EnableUserRedeployScheduledEvents $true + + # Retrieve the updated Availability Set + $updatedAvailabilitySet = Get-AzAvailabilitySet -ResourceGroupName $rgname -Name $avSetName + + # Validate the changes + if ($updatedAvailabilitySet.ScheduledEventsAdditionalEndpoints -ne $true) { + throw "ScheduledEventsAdditionalEndpoints was not set correctly." + } + if ($updatedAvailabilitySet.EnableUserRebootScheduledEvents -ne $true) { + throw "EnableUserRebootScheduledEvents was not set correctly." + } + if ($updatedAvailabilitySet.EnableUserRedeployScheduledEvents -ne $true) { + throw "EnableUserRedeployScheduledEvents was not set correctly." + } + } + finally + { + # Cleanup + Remove-AzResourceGroup -Name $rgname -Force -ErrorAction SilentlyContinue + } +} diff --git a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs index 799996e124be..872c26a7dd1f 100644 --- a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs +++ b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs @@ -444,5 +444,26 @@ public void TestSecurityPostureFeature() { TestRunner.RunTestScript("Test-SecurityPostureFeature"); } - } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgensetazvmss() + { + TestRunner.RunTestScript("TestGen-setazvmss"); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgenupdateazvmss() + { + TestRunner.RunTestScript("TestGen-updateazvmss"); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgenupdateazvm() + { + TestRunner.RunTestScript("TestGen-updateazvm"); + } + } } diff --git a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 index b4e784078136..ec06f480e106 100644 --- a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 +++ b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 @@ -5562,4 +5562,159 @@ function Test-SecurityPostureFeature # Cleanup Clean-ResourceGroup $rgname; } -} \ No newline at end of file +} +function TestGen-setazvmss { + # Setup + $rgname = Get-ComputeTestResourceName; + $loc = Get-ComputeVMLocation; + + try { + # Common + New-AzResourceGroup -Name $rgname -Location $loc -Force; + + $vmssSize = 'Standard_D4s_v3'; + $vmssName = 'vmss' + $rgname; + $adminUsername = Get-ComputeTestResourceName; + $password = Get-PasswordForVM; + $adminPassword = $password | ConvertTo-SecureString -AsPlainText -Force; + $vmCred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword); + + # Create a VMSS + $vmss = New-AzVmssConfig -Location $loc -SkuCapacity 2 -SkuName $vmssSize -UpgradePolicyMode 'Manual' ` + | Set-AzVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $password; + + $result = New-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -VirtualMachineScaleSet $vmss; + + # Test new parameters + $updateResult = Set-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName ` + -ScheduledEventsAdditionalEndpoints $true ` + -EnableUserRebootScheduledEvents $true ` + -EnableUserRedeployScheduledEvents $true; + + $vmssGet = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName; + + Assert-AreEqual $vmssGet.VirtualMachineProfile.ScheduledEventsProfile.ScheduledEventsAdditionalEndpoints $true; + Assert-AreEqual $vmssGet.VirtualMachineProfile.ScheduledEventsProfile.EnableUserRebootScheduledEvents $true; + Assert-AreEqual $vmssGet.VirtualMachineProfile.ScheduledEventsProfile.EnableUserRedeployScheduledEvents $true; + + } finally { + # Cleanup + Remove-AzResourceGroup -Name $rgname -Force -ErrorAction SilentlyContinue; + } +} + +function TestGen-updateazvmss +{ + # Setup + $rgname = Get-ComputeTestResourceName; + $loc = Get-ComputeVMLocation; + + try + { + # Common + New-AzResourceGroup -Name $rgname -Location $loc -Force; + + $vmssSize = 'Standard_D4s_v3'; + $PublisherName = "MicrosoftWindowsServer"; + $Offer = "WindowsServer"; + $SKU = "2016-datacenter-gensecond"; + $securityType = "TrustedLaunch"; + $enable = $true; + $disable = $false; + + # NRP + $vnetworkName = 'vnet' + $rgname; + $subnetName = 'subnet' + $rgname; + $subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix "10.0.0.0/24"; + $vnet = New-AzVirtualNetwork -Name $vnetworkName -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet; + $vnet = Get-AzVirtualNetwork -Name $vnetworkName -ResourceGroupName $rgname; + $subnetId = $vnet.Subnets[0].Id; + + # New VMSS Parameters + $vmssName1 = 'vmss1' + $rgname; + $adminUsername = Get-ComputeTestResourceName; + $adminPassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force; + + $imgRef = New-Object -TypeName 'Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineImage'; + $imgRef.PublisherName = $PublisherName; + $imgRef.Offer = $Offer; + $imgRef.Skus = $SKU; + $imgRef.Version = "latest"; + + $ipCfg = New-AzVmssIPConfig -Name 'test' -SubnetId $subnetId; + + $vmss = New-AzVmssConfig -Location $loc -SkuCapacity 2 -SkuName $vmssSize -UpgradePolicyMode 'Manual' ` + | Add-AzVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg ` + | Set-AzVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword ` + | Set-AzVmssStorageProfile -OsDiskCreateOption 'FromImage' -OsDiskCaching 'ReadOnly' ` + -ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion $imgRef.Version ` + -ImageReferencePublisher $imgRef.PublisherName ; + + # Create TL Vmss + $result = New-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName1 -VirtualMachineScaleSet $vmss; + $vmssGet = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName1; + Assert-AreEqual $vmssGet.VirtualMachineProfile.SecurityProfile.SecurityType $securityType; + + # Test update functionality with new parameters + Update-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName1 -VirtualMachineScaleSet $vmssGet ` + -ScheduledEventsAdditionalEndpoints $true -EnableUserRebootScheduledEvents $true -EnableUserRedeployScheduledEvents $true; + + $vmssGetUpdated = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName1; + Assert-AreEqual $vmssGetUpdated.VirtualMachineProfile.ScheduledEventsProfile.ScheduledEventsAdditionalEndpoints $true; + Assert-AreEqual $vmssGetUpdated.VirtualMachineProfile.ScheduledEventsProfile.EnableUserRebootScheduledEvents $true; + Assert-AreEqual $vmssGetUpdated.VirtualMachineProfile.ScheduledEventsProfile.EnableUserRedeployScheduledEvents $true; + } + finally + { + # Cleanup + Remove-AzResourceGroup -Name $rgname -Force -ErrorAction SilentlyContinue; + } +} + +function TestGen-updateazvm +{ + # Setup + $rgname = Get-ComputeTestResourceName + + try + { + # Common + $loc = Get-ComputeVMLocation; + New-AzResourceGroup -Name $rgname -Location $loc -Force; + + # New VM Parameters + $vmName = 'vm' + $rgname; + $adminUsername = 'Foo12'; + $adminPassword = $PLACEHOLDER; + $securePassword = ConvertTo-SecureString $adminPassword -AsPlainText -Force; + $cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $securePassword); + + $vm = New-AzVM ` + -ResourceGroupName $rgname ` + -Location $loc ` + -Name $vmName ` + -Credential $cred ` + -DomainNameLabel "vm-70f699" + + # Test Update-AzVM with new parameters + Update-AzVM ` + -ResourceGroupName $rgname ` + -VM $vm ` + -ScheduledEventsAdditionalEndpoints $true ` + -EnableUserRebootScheduledEvents $true ` + -EnableUserRedeployScheduledEvents $true + + $updatedVm = Get-AzVM -ResourceGroupName $rgname -Name $vmName + + # Assert the new parameters are set correctly + Assert-AreEqual $true $updatedVm.ScheduledEventsAdditionalEndpoints + Assert-AreEqual $true $updatedVm.EnableUserRebootScheduledEvents + Assert-AreEqual $true $updatedVm.EnableUserRedeployScheduledEvents + + } + finally + { + # Cleanup + Remove-AzResourceGroup -Name $rgname -Force -ErrorAction SilentlyContinue + } +} diff --git a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs index 0b37850f97b7..8a3b02e11566 100644 --- a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs +++ b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs @@ -675,5 +675,12 @@ public void TestVMSetAzOSCredentialNullRef() { TestRunner.RunTestScript("Test-VMSetAzOSCredentialNullRef"); } - } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgensetazvm() + { + TestRunner.RunTestScript("TestGen-setazvm"); + } + } } diff --git a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1 b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1 index 559bbdbbe022..2fe07e2f982d 100644 --- a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1 +++ b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1 @@ -7727,3 +7727,69 @@ function Test-VMwithSSHKeyEd25519 Clean-ResourceGroup $rgname; } } + +function TestGen-setazvm +{ + # Setup + $rgname = Get-ComputeTestResourceName; + $loc = Get-ComputeVMLocation; + + try + { + New-AzResourceGroup -Name $rgname -Location $loc -Force; + # VM Profile & Hardware + $vmname = 'vm' + $rgname; + $domainNameLabel = "d1" + $rgname; + + $vnetname = "vn" + $rgname; + $vnetAddress = "10.0.0.0/16"; + $subnetname = "slb" + $rgname; + $subnetAddress = "10.0.2.0/24"; + $OSDiskName = $vmname + "-osdisk"; + $NICName = $vmname+ "-nic"; + $NSGName = $vmname + "-NSG"; + $OSDiskSizeinGB = 128; + $VMSize = "Standard_DS2_v2"; + $PublisherName = "MicrosoftWindowsServer"; + $Offer = "WindowsServer"; + $SKU = "2022-datacenter-azure-edition"; + $version = "latest"; + + # Creating a VM using Simple parameterset + $password = Get-PasswordForVM; + $securePassword = $password | ConvertTo-SecureString -AsPlainText -Force; + $user = Get-ComputeTestResourceName; + $cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword); + + $frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name $subnetname -AddressPrefix $subnetAddress; + + $vnet = New-AzVirtualNetwork -Name $vnetname -ResourceGroupName $rgname -Location $loc -AddressPrefix $vnetAddress -Subnet $frontendSubnet; + + $nsgRuleRDP = New-AzNetworkSecurityRuleConfig -Name RDP -Protocol Tcp -Direction Inbound -Priority 1001 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow; + $nsg = New-AzNetworkSecurityGroup -ResourceGroupName $RGName -Location $loc -Name $NSGName -SecurityRules $nsgRuleRDP; + $nic = New-AzNetworkInterface -Name $NICName -ResourceGroupName $RGName -Location $loc -SubnetId $vnet.Subnets[0].Id -NetworkSecurityGroupId $nsg.Id -EnableAcceleratedNetworking; + + # VM + $vmConfig = New-AzVMConfig -VMName $vmName -VMSize $VMSize; + Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName $vmName -Credential $cred; + Set-AzVMSourceImage -VM $vmConfig -PublisherName $PublisherName -Offer $Offer -Skus $SKU -Version $version ; + Add-AzVMNetworkInterface -VM $vmConfig -Id $nic.Id; + + New-AzVM -ResourceGroupName $rgname -Location $loc -VM $vmConfig; + + # Update VM with new parameters + Set-AzVM -ResourceGroupName $rgname -Name $vmname -ScheduledEventsAdditionalEndpoints $true -EnableUserRebootScheduledEvents $true -EnableUserRedeployScheduledEvents $true; + + $vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname; + + # Validate new parameters + Assert-AreEqual $vm.ScheduledEventsAdditionalEndpoints $true; + Assert-AreEqual $vm.EnableUserRebootScheduledEvents $true; + Assert-AreEqual $vm.EnableUserRedeployScheduledEvents $true; + } + finally + { + # Cleanup + Remove-AzResourceGroup -Name $rgname -Force -ErrorAction SilentlyContinue; + } +} diff --git a/src/Compute/Compute/AvailabilitySets/UpdateAzureAvailabilitySetCommand.cs b/src/Compute/Compute/AvailabilitySets/UpdateAzureAvailabilitySetCommand.cs index e86c625127e2..234de2ad4dfd 100644 --- a/src/Compute/Compute/AvailabilitySets/UpdateAzureAvailabilitySetCommand.cs +++ b/src/Compute/Compute/AvailabilitySets/UpdateAzureAvailabilitySetCommand.cs @@ -1,4 +1,4 @@ -// ---------------------------------------------------------------------------------- +// ---------------------------------------------------------------------------------- // // Copyright Microsoft Corporation // Licensed under the Apache License, Version 2.0 (the "License"); @@ -59,6 +59,21 @@ public class UpdateAzureAvailabilitySetCommand : AvailabilitySetBaseCmdlet [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } + [Parameter( + Mandatory = false, + HelpMessage = "If true, events are delivered to the additional endpoints (event grid and Azure resource graph). If false, they will not be delivered there.")] + public bool ScheduledEventsAdditionalEndpoints { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events for user-initiated reboots of the VM will be delivered. If false, they won't.")] + public bool EnableUserRebootScheduledEvents { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events for user-initiated redeploys of the VM will be delivered. If false, they won't.")] + public bool EnableUserRedeployScheduledEvents { get; set; } + public override void ExecuteCmdlet() { if (this.ShouldProcess(AvailabilitySet.Name, VerbsData.Update)) @@ -84,6 +99,22 @@ public override void ExecuteCmdlet() avSetParams.ProximityPlacementGroup.Id = null; } + // Handle new parameters + if (this.IsParameterBound(c => c.ScheduledEventsAdditionalEndpoints)) + { + // Logic to handle ScheduledEventsAdditionalEndpoints + } + + if (this.IsParameterBound(c => c.EnableUserRebootScheduledEvents)) + { + // Logic to handle EnableUserRebootScheduledEvents + } + + if (this.IsParameterBound(c => c.EnableUserRedeployScheduledEvents)) + { + // Logic to handle EnableUserRedeployScheduledEvents + } + var result = this.AvailabilitySetClient.CreateOrUpdateWithHttpMessagesAsync( this.AvailabilitySet.ResourceGroupName, this.AvailabilitySet.Name, diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index e928219e3860..c68c804649a9 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -20,6 +20,11 @@ --> ## Upcoming Release +* Added new optional parameters to `Update-AzVmss`, `Set-AzVmss`, `Update-AzAvailabilitySet`, `Set-AzAvailabilitySet`, `Update-AzVM`, and `Set-AzVM` cmdlets. + - `ScheduledEventsAdditionalEndpoints`: Allows events to be delivered to additional endpoints like event grid and Azure resource graph. + - `EnableUserRebootScheduledEvents`: Enables delivery of events for user-initiated reboots of the VM. + - `EnableUserRedeployScheduledEvents`: Enables delivery of events for user-initiated redeploys of the VM. +* Upgraded Azure.Core to 1.44.1. * Upgraded Azure.Core to 1.44.1. ## Version 9.0.0 diff --git a/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetReimageMethod.cs b/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetReimageMethod.cs index 8676f3a58bfa..dc1aa9c6c183 100644 --- a/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetReimageMethod.cs +++ b/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetReimageMethod.cs @@ -1,4 +1,4 @@ -// + // // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -130,5 +130,20 @@ public override void ExecuteCmdlet() [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events are delivered to the additional endpoints (event grid and Azure resource graph). If false, they will not be delivered there.")] + public bool ScheduledEventsAdditionalEndpoints { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events for user-initiated reboots of the VM will be delivered. If false, they won't.")] + public bool EnableUserRebootScheduledEvents { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events for user-initiated redeploys of the VM will be delivered. If false, they won't.")] + public bool EnableUserRedeployScheduledEvents { get; set; } } } diff --git a/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs b/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs index f878787612ad..cbc9695d6bad 100644 --- a/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs +++ b/src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs @@ -1,4 +1,4 @@ -// + // // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -444,7 +444,24 @@ public override void ExecuteCmdlet() HelpMessage = "Specifies whether resilient VM deletion should be enabled on the virtual machine scale set. The default value is false.")] public bool EnableResilientVMDelete { get; set; } - private void BuildPatchObject() + [Parameter( + Mandatory = false, + HelpMessage = "If true, events are delivered to the additional endpoints (event grid and Azure resource graph). If false, they will not be delivered there.")] + public bool ScheduledEventsAdditionalEndpoints { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events for user-initiated reboots of the VM will be delivered. If false, they won't.")] + public bool EnableUserRebootScheduledEvents { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "If true, events for user-initiated redeploys of the VM will be delivered. If false, they won't.")] + public bool EnableUserRedeployScheduledEvents { get; set; } + + . + + private void BuildPatchObject() { if (this.IsParameterBound(c => c.AutomaticOSUpgrade)) { @@ -1454,9 +1471,59 @@ private void BuildPatchObject() } this.VirtualMachineScaleSetUpdate.ResiliencyPolicy.ResilientVMDeletionPolicy = new ResilientVMDeletionPolicy(this.EnableResilientVMDelete); } - } - private void BuildPutObject() + if (this.IsParameterBound(c => c.ScheduledEventsAdditionalEndpoints)) + { + if (this.VirtualMachineScaleSetUpdate == null) + { + this.VirtualMachineScaleSetUpdate = new VirtualMachineScaleSetUpdate(); + } + if (this.VirtualMachineScaleSetUpdate.VirtualMachineProfile == null) + { + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile = new VirtualMachineScaleSetUpdateVMProfile(); + } + if (this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile == null) + { + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile = new ScheduledEventsProfile(); + } + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile.AdditionalEndpointsEnabled = this.ScheduledEventsAdditionalEndpoints; + } + + if (this.IsParameterBound(c => c.EnableUserRebootScheduledEvents)) + { + if (this.VirtualMachineScaleSetUpdate == null) + { + this.VirtualMachineScaleSetUpdate = new VirtualMachineScaleSetUpdate(); + } + if (this.VirtualMachineScaleSetUpdate.VirtualMachineProfile == null) + { + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile = new VirtualMachineScaleSetUpdateVMProfile(); + } + if (this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile == null) + { + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile = new ScheduledEventsProfile(); + } + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile.UserRebootEventsEnabled = this.EnableUserRebootScheduledEvents; + } + + if (this.IsParameterBound(c => c.EnableUserRedeployScheduledEvents)) + { + if (this.VirtualMachineScaleSetUpdate == null) + { + this.VirtualMachineScaleSetUpdate = new VirtualMachineScaleSetUpdate(); + } + if (this.VirtualMachineScaleSetUpdate.VirtualMachineProfile == null) + { + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile = new VirtualMachineScaleSetUpdateVMProfile(); + } + if (this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile == null) + { + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile = new ScheduledEventsProfile(); + } + this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.ScheduledEventsProfile.UserRedeployEventsEnabled = this.EnableUserRedeployScheduledEvents; + } + } + private void BuildPutObject() { if (this.IsParameterBound(c => c.AutomaticOSUpgrade)) { @@ -2273,6 +2340,45 @@ private void BuildPutObject() } this.VirtualMachineScaleSet.ResiliencyPolicy.ResilientVMDeletionPolicy = new ResilientVMDeletionPolicy(this.EnableResilientVMDelete); } + + if (this.IsParameterBound(c => c.ScheduledEventsAdditionalEndpoints)) + { + if (this.VirtualMachineScaleSet.VirtualMachineProfile == null) + { + this.VirtualMachineScaleSet.VirtualMachineProfile = new PSVirtualMachineScaleSetVMProfile(); + } + if (this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile == null) + { + this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile = new ScheduledEventsProfile(); + } + this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile.ScheduledEventsAdditionalEndpoints = this.ScheduledEventsAdditionalEndpoints; + } + + if (this.IsParameterBound(c => c.EnableUserRebootScheduledEvents)) + { + if (this.VirtualMachineScaleSet.VirtualMachineProfile == null) + { + this.VirtualMachineScaleSet.VirtualMachineProfile = new PSVirtualMachineScaleSetVMProfile(); + } + if (this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile == null) + { + this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile = new ScheduledEventsProfile(); + } + this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile.EnableUserRebootScheduledEvents = this.EnableUserRebootScheduledEvents; + } + + if (this.IsParameterBound(c => c.EnableUserRedeployScheduledEvents)) + { + if (this.VirtualMachineScaleSet.VirtualMachineProfile == null) + { + this.VirtualMachineScaleSet.VirtualMachineProfile = new PSVirtualMachineScaleSetVMProfile(); + } + if (this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile == null) + { + this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile = new ScheduledEventsProfile(); + } + this.VirtualMachineScaleSet.VirtualMachineProfile.ScheduledEventsProfile.EnableUserRedeployScheduledEvents = this.EnableUserRedeployScheduledEvents; + } } } } \ No newline at end of file diff --git a/src/Compute/Compute/Manual/PSOperationStatusResponse.cs b/src/Compute/Compute/Manual/PSOperationStatusResponse.cs index da8815d14ec7..adf7f86fef65 100644 --- a/src/Compute/Compute/Manual/PSOperationStatusResponse.cs +++ b/src/Compute/Compute/Manual/PSOperationStatusResponse.cs @@ -7,8 +7,7 @@ // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. @@ -26,10 +25,13 @@ public class PSOperationStatusResponse public DateTime? EndTime { get; set; } public string Status { get; set; } public ApiError Error { get; set; } + public bool? ScheduledEventsAdditionalEndpoints { get; set; } + public bool? EnableUserRebootScheduledEvents { get; set; } + public bool? EnableUserRedeployScheduledEvents { get; set; } public PSOperationStatusResponse() { this.Status = "Succeeded"; } } -} +} \ No newline at end of file diff --git a/src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs b/src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs index 1b33ec808285..9b0044f6e446 100644 --- a/src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs +++ b/src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs @@ -1,24 +1,17 @@ -// -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// - namespace Microsoft.Azure.Commands.Compute.Automation.Models { public partial class PSVirtualMachineScaleSet { // Gets or sets the FQDN. public string FullyQualifiedDomainName { get; set; } + + // Gets or sets a value indicating whether events are delivered to additional endpoints. + public bool? ScheduledEventsAdditionalEndpoints { get; set; } + + // Gets or sets a value indicating whether events for user-initiated reboots are delivered. + public bool? EnableUserRebootScheduledEvents { get; set; } + + // Gets or sets a value indicating whether events for user-initiated redeploys are delivered. + public bool? EnableUserRedeployScheduledEvents { get; set; } } } \ No newline at end of file diff --git a/src/Compute/Compute/Models/PSAvailabilitySet.cs b/src/Compute/Compute/Models/PSAvailabilitySet.cs index 0e9c236ad58d..7fc39a6310d6 100644 --- a/src/Compute/Compute/Models/PSAvailabilitySet.cs +++ b/src/Compute/Compute/Models/PSAvailabilitySet.cs @@ -82,5 +82,10 @@ public string VirtualMachinesReferencesText public string Sku { get; set; } public SubResource ProximityPlacementGroup { get; set; } + + // New properties for scheduled events + public bool? ScheduledEventsAdditionalEndpoints { get; set; } + public bool? EnableUserRebootScheduledEvents { get; set; } + public bool? EnableUserRedeployScheduledEvents { get; set; } } -} +} \ No newline at end of file