@@ -609,7 +609,7 @@ function Test-AzMaintenanceUpdate
609
609
610
610
<#
611
611
. SYNOPSIS
612
- Test New-AzMaintenanceConfiguration, Get -AzApplyUpdate, Remove-AzMaintenanceConfiguration
612
+ Test New-AzMaintenanceConfiguration, New -AzApplyUpdate, Remove-AzMaintenanceConfiguration
613
613
#>
614
614
function Test-AzApplyUpdateCancelConfiguration
615
615
{
@@ -660,7 +660,175 @@ function Test-AzApplyUpdateCancelConfiguration
660
660
# Cleanup
661
661
Clean - ResourceGroup $resourceGroupName
662
662
}
663
- }
663
+ }
664
+
665
+ <#
666
+ . SYNOPSIS
667
+ Test New-AzMaintenanceConfiguration, New-AzConfigurationAssignment, Get-AzApplyUpdate
668
+ #>
669
+ function Test-GetAzApplyUpdateWithParentResource
670
+ {
671
+ $actualStartTime = (Get-Date - AsUTC).AddMinutes(12 )
672
+ $resourceGroupName = Get-RandomResourceGroupName
673
+ $maintenanceConfigurationName = Get-RandomMaintenanceConfigurationName
674
+ $dedicatedHostGroupName = Get-RandomDedicatedHostGroupName
675
+ $dedicatedHostName = Get-RandomDedicatedHostName
676
+ $location = " eastus"
677
+ $maintenanceScope = " Host"
678
+ $duration = " 02:00"
679
+ $actualStartDateTime = $actualStartTime.ToString (" yyyy-MM-dd HH:mm" )
680
+ $startDateTime = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer ]::GetVariable(" startDateTime" , $actualStartDateTime )
681
+ $expirationDateTime = " 9999-12-31 00:00"
682
+ $recurEvery = " Day"
683
+ $timezone = " UTC"
684
+ $providerName = " Microsoft.Compute"
685
+ $resourceType = " hosts"
686
+ $resourceParentType = " hostGroups"
687
+ $applyUpdateName = " default"
688
+
689
+ try
690
+ {
691
+ New-AzResourceGroup - Name $resourceGroupName - Location $location
692
+
693
+ $dedicatedHostId = New-DedicatedHost $dedicatedHostName $dedicatedHostGroupName $resourceGroupName $location
694
+
695
+ # ## Host maintenance config
696
+ $maintenanceConfiguration = New-AzMaintenanceConfiguration `
697
+ - ResourceGroupName $resourceGroupName `
698
+ - Name $maintenanceConfigurationName `
699
+ - MaintenanceScope $maintenanceScope `
700
+ - Location $location `
701
+ - Timezone $timezone `
702
+ - StartDateTime $startDateTime `
703
+ - ExpirationDateTime $expirationDateTime `
704
+ - Duration $duration `
705
+ - RecurEvery $recurEvery
706
+
707
+ Assert-AreEqual $maintenanceConfiguration.Name $maintenanceConfigurationName
708
+
709
+ # ## Wait few minutes so that the resource is available for configuration assignment
710
+ Start-TestSleep - Seconds (15 * 60 )
711
+
712
+ # ## Create configuration assignment
713
+ $configurationAssignment = New-AzConfigurationAssignment `
714
+ - ResourceGroupName $resourceGroupName `
715
+ - Location $location `
716
+ - ResourceName $dedicatedHostName `
717
+ - ResourceType $resourceType `
718
+ - ResourceParentName $dedicatedHostGroupName `
719
+ - ResourceParentType $resourceParentType `
720
+ - ProviderName $providerName `
721
+ - ConfigurationAssignmentName $maintenanceConfigurationName `
722
+ - MaintenanceConfigurationId $maintenanceConfiguration.Id
723
+
724
+ Assert-AreEqual $configurationAssignment.Name $maintenanceConfigurationName
725
+
726
+ # ## Make Get-AzApplyUpdate call
727
+ $applyUpdateResponse = Get-AzApplyUpdate `
728
+ - ResourceGroupName $resourceGroupName `
729
+ - ProviderName $providerName `
730
+ - ResourceType $resourceType `
731
+ - ResourceName $dedicatedHostName `
732
+ - ResourceParentType $resourceParentType `
733
+ - ResourceParentName $dedicatedHostGroupName `
734
+ - ApplyUpdateName $applyUpdateName
735
+
736
+ Assert-AreEqual $applyUpdateResponse.ResourceId $dedicatedHostId
737
+ }
738
+ finally
739
+ {
740
+ Clean - ResourceGroup $resourceGroupName
741
+ }
742
+ }
743
+
744
+ <#
745
+ . SYNOPSIS
746
+ Test New-AzMaintenanceConfiguration, New-AzConfigurationAssignment, Get-AzApplyUpdate
747
+ #>
748
+ function Test-GetAzApplyUpdateWithoutParentResource
749
+ {
750
+ $actualStartTime = (Get-Date - AsUTC).AddMinutes(12 )
751
+ $resourceGroupName = Get-RandomResourceGroupName
752
+ $maintenanceConfigurationName = Get-RandomMaintenanceConfigurationName
753
+ $virtualMachineName = Get-RandomVirtualMachineName
754
+ $location = " westus"
755
+ $maintenanceScope = " InGuestPatch"
756
+ $duration = " 02:00"
757
+ $actualStartDateTime = $actualStartTime.ToString (" yyyy-MM-dd HH:mm" )
758
+ $startDateTime = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer ]::GetVariable(" startDateTime" , $actualStartDateTime )
759
+ $expirationDateTime = " 9999-12-31 00:00"
760
+ $recurEvery = " Day"
761
+ $timezone = " UTC"
762
+ $extensionProperty = @ {" inGuestPatchMode" = " User" }
763
+ $rebootOption = " IfRequired" ;
764
+ $windowsParameterClassificationToInclude = " FeaturePack" , " ServicePack" ;
765
+ $windowsParameterKbNumberToInclude = " KB123456" , " KB123466" ;
766
+ $windowsParameterKbNumberToExclude = " KB123456" , " KB123466" ;
767
+ $linuxParameterClassificationToInclude = " Other" ;
768
+ $linuxParameterPackageNameMaskToInclude = " apt" , " httpd" ;
769
+ $linuxParameterPackageNameMaskToExclude = " ppt" , " userpk" ;
770
+ $providerName = " Microsoft.Compute"
771
+ $resourceType = " virtualmachines"
772
+ $applyUpdateName = " default"
773
+
774
+ try
775
+ {
776
+ New-AzResourceGroup - Name $resourceGroupName - Location $location
777
+
778
+ $virtualMachineId = New-VirtualMachine $virtualMachineName $resourceGroupName $location
779
+
780
+ # ## InGuestPatch maintenance config
781
+ $maintenanceConfiguration = New-AzMaintenanceConfiguration `
782
+ - ResourceGroupName $resourceGroupName `
783
+ - Name $maintenanceConfigurationName `
784
+ - MaintenanceScope $maintenanceScope `
785
+ - Location $location `
786
+ - Timezone $timezone `
787
+ - StartDateTime $startDateTime `
788
+ - ExpirationDateTime $expirationDateTime `
789
+ - Duration $duration `
790
+ - RecurEvery $recurEvery `
791
+ - ExtensionProperty $extensionProperty `
792
+ - InstallPatchRebootSetting $rebootOption `
793
+ - WindowParameterClassificationToInclude $windowsParameterClassificationToInclude `
794
+ - WindowParameterKbNumberToInclude $windowsParameterKbNumberToInclude `
795
+ - WindowParameterKbNumberToExclude $windowsParameterKbNumberToExclude `
796
+ - LinuxParameterPackageNameMaskToInclude $linuxParameterPackageNameMaskToInclude `
797
+ - LinuxParameterClassificationToInclude $linuxParameterClassificationToInclude `
798
+ - LinuxParameterPackageNameMaskToExclude $linuxParameterPackageNameMaskToExclude
799
+
800
+ Assert-AreEqual $maintenanceConfiguration.Name $maintenanceConfigurationName
801
+
802
+ # ## Wait few minutes so that the resource is available for configuration assignment
803
+ Start-TestSleep - Seconds (15 * 60 )
804
+
805
+ # ## Create configuration assignment
806
+ $configurationAssignment = New-AzConfigurationAssignment `
807
+ - ResourceGroupName $resourceGroupName `
808
+ - Location $location `
809
+ - ResourceName $virtualMachineName `
810
+ - ResourceType $resourceType `
811
+ - ProviderName $providerName `
812
+ - ConfigurationAssignmentName $maintenanceConfigurationName `
813
+ - MaintenanceConfigurationId $maintenanceConfiguration.Id
814
+
815
+ Assert-AreEqual $configurationAssignment.Name $maintenanceConfigurationName
816
+
817
+ # ## Make Get-AzApplyUpdate call
818
+ $applyUpdateResponse = Get-AzApplyUpdate `
819
+ - ResourceGroupName $resourceGroupName `
820
+ - ProviderName $providerName `
821
+ - ResourceType $resourceType `
822
+ - ResourceName $virtualMachineName `
823
+ - ApplyUpdateName $applyUpdateName
824
+
825
+ Assert-AreEqual $applyUpdateResponse.ResourceId $virtualMachineId
826
+ }
827
+ finally
828
+ {
829
+ Clean - ResourceGroup $resourceGroupName
830
+ }
831
+ }
664
832
665
833
<#
666
834
. SYNOPSIS
0 commit comments