Skip to content

Commit c57ce10

Browse files
authored
Az.Compute - MSP AddProxyAgentExtension parameter (#28634)
1 parent fa532bd commit c57ce10

File tree

20 files changed

+5446
-17
lines changed

20 files changed

+5446
-17
lines changed

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,5 +479,12 @@ public void TestProxyAgentSetting()
479479
{
480480
TestRunner.RunTestScript("Test-ProxyAgentSetting");
481481
}
482+
483+
[Fact]
484+
[Trait(Category.AcceptanceType, Category.CheckIn)]
485+
public void TestVirtualMachineScaleSetAddProxyAgentExtension()
486+
{
487+
TestRunner.RunTestScript("Test-VirtualMachineScaleSetAddProxyAgentExtension");
488+
}
482489
}
483490
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5965,4 +5965,54 @@ function Test-ProxyAgentSetting
59655965
# Cleanup
59665966
Clean-ResourceGroup $rgname;
59675967
}
5968+
}
5969+
5970+
<#
5971+
.SYNOPSIS
5972+
Test-VirtualMachineScaleSetAddProxyAgentExtension creates a VMSS with Enabled ProxyAgent and added ProxyAgentExtension
5973+
#>
5974+
function Test-VirtualMachineScaleSetAddProxyAgentExtension
5975+
{
5976+
# Setup
5977+
$rgname = Get-ComputeTestResourceName;
5978+
$loc = "eastus2";
5979+
5980+
5981+
try
5982+
{
5983+
# Common
5984+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
5985+
5986+
$vmssName = 'vmss' + $rgname;
5987+
$domainNameLabel1 = "d1" + $rgname;
5988+
5989+
$adminUsername = Get-ComputeTestResourceName;
5990+
$password = Get-PasswordForVM;
5991+
$adminPassword = $password | ConvertTo-SecureString -AsPlainText -Force;
5992+
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword);
5993+
$linuxImage = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest"
5994+
5995+
# Case 1: Create using simple parameter set
5996+
$vmss = New-AzVmss -ResourceGroupName $rgname -Location $loc -Credential $cred -VMScaleSetName $vmssName -DomainNameLabel $domainNameLabel1 -Image $linuxImage -EnableProxyAgent -AddProxyAgentExtension
5997+
5998+
# verify
5999+
Assert-AreEqual $vmss.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.Enabled $true
6000+
6001+
6002+
# Update vmss to add proxy agent extension
6003+
$VMSS = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName
6004+
$VMSS = Set-AzVmssProxyAgentSetting -VirtualMachineScaleSet $VMSS -EnableProxyAgent $true -AddProxyAgentExtension $false
6005+
$vmssUpdated = Update-AzVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $VMSS
6006+
6007+
6008+
6009+
# Validate
6010+
Assert-AreEqual $vmssUpdated.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.Enabled $true
6011+
Assert-AreEqual $vmssUpdated.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension $false
6012+
}
6013+
finally
6014+
{
6015+
# Cleanup
6016+
Clean-ResourceGroup $rgname;
6017+
}
59686018
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,19 @@ public void TestEncryptionIdentityNotPartOfAssignedIdentitiesInAzureVm()
682682
{
683683
TestRunner.RunTestScript("Test-EncryptionIdentityNotPartOfAssignedIdentitiesInAzureVm");
684684
}
685+
685686
[Fact]
686687
[Trait(Category.AcceptanceType, Category.CheckIn)]
687688
public void TestVirtualMachinePlacement()
688689
{
689690
TestRunner.RunTestScript("Test-VirtualMachinePlacement");
690691
}
692+
693+
[Fact]
694+
[Trait(Category.AcceptanceType, Category.CheckIn)]
695+
public void TestVirtualMachineAddProxyAgentExtension()
696+
{
697+
TestRunner.RunTestScript("Test-VirtualMachineAddProxyAgentExtension");
698+
}
691699
}
692700
}

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7915,7 +7915,7 @@ function Test-VirtualMachinePlacement
79157915
$user = Get-ComputeTestResourceName;
79167916
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
79177917

7918-
# create VM with placement feature
7918+
# create VM with placement feature
79197919
$vmname = '1' + $rgname;
79207920
$domainNameLabel = "d1" + $rgname;
79217921
$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -Image CentOS85Gen2 -DomainNameLabel $domainNameLabel -ZonePlacementPolicy "Any" -IncludeZone "1","2" -AlignRegionalDisksToVMZone
@@ -7938,4 +7938,40 @@ function Test-VirtualMachinePlacement
79387938
# Cleanup
79397939
Clean-ResourceGroup $rgname;
79407940
}
7941-
}
7941+
}
7942+
7943+
<#
7944+
.SYNOPSIS
7945+
Test-VirtualMachineAddProxyAgentExtension creates a VM with Enabled ProxyAgent and added ProxyAgentExtension
7946+
#>
7947+
function Test-VirtualMachineAddProxyAgentExtension
7948+
{
7949+
# Setup
7950+
$resourceGroupName = Get-ComputeTestResourceName;
7951+
$adminUsername = Get-ComputeTestResourceName;
7952+
$adminPassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
7953+
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword);
7954+
$vmName = 'VM1';
7955+
$imageName = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest";
7956+
$domainNameLabel = "d1" + $resourceGroupName;
7957+
7958+
7959+
try
7960+
{
7961+
New-AzVM -ResourceGroupName $resourceGroupName -Name $VMName -Credential $cred -image $imageName -DomainNameLabel $domainNameLabel -Location 'eastus2' -EnableProxyAgent -AddProxyAgentExtension
7962+
7963+
# Update vm to add proxy agent extension
7964+
$VM = Get-AzVM -ResourceGroupName $resourceGroupName -VMName $vmName
7965+
$VM = Set-AzVMProxyAgentSetting -VM $VM -EnableProxyAgent $true -AddProxyAgentExtension $false
7966+
Update-AzVM -ResourceGroupName $resourceGroupName -VM $VM
7967+
7968+
# Validate
7969+
Assert-AreEqual $VM.SecurityProfile.ProxyAgentSettings.Enabled $true
7970+
Assert-AreEqual $VM.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension $false
7971+
}
7972+
finally
7973+
{
7974+
# Cleanup
7975+
Clean-ResourceGroup $resourceGroupName;
7976+
}
7977+
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests/TestVirtualMachineScaleSetAddProxyAgentExtension.json

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

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

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

src/Compute/Compute/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
-->
2222
## Upcoming Release
2323
* Added `-Redeploy` switch parameter for `Update-AzHost` cmdlet to enable dedicated host redeployment.
24+
* ComputeRP related cmdlets will now use 2025-04-01 version of the ComputeRP API.
25+
* Added `-AddProxyAgentExtension` parameter (Switch) to `New-AzVmss` and `New-AzVM`
26+
* Added `-AddProxyAgentExtension` parameter (Bool) to `Set-AzVMProxyAgentSetting` and `Set-AzVmssProxyAgentSetting`
2427

2528
## Version 10.4.0
2629
* Added `-InstantAccessDurationMinutes` parameter to New-AzSnapshotConfig.

src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/SetAzVmssProxyAgentSetting.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ public class SetAzureVmssProxySetting : Microsoft.Azure.Commands.ResourceManager
6969
HelpMessage = "Specifies the InVMAccessControlProfileVersion resource id in the IMDS enpoint. Format of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}")]
7070
public string ImdsProfile { get; set; }
7171

72+
[Parameter(
73+
Mandatory = false,
74+
ValueFromPipelineByPropertyName = true,
75+
HelpMessage = "Specify whether to implicitly install the ProxyAgent Extension. This option is currently applicable only for Linux Os.")]
76+
public bool? AddProxyAgentExtension { get; set; }
77+
7278
public override void ExecuteCmdlet()
7379
{
7480
if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
@@ -96,6 +102,11 @@ public override void ExecuteCmdlet()
96102
})
97103
};
98104

105+
if (this.MyInvocation.BoundParameters.ContainsKey(nameof(AddProxyAgentExtension)))
106+
{
107+
this.VirtualMachineScaleSet.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension = this.AddProxyAgentExtension;
108+
}
109+
99110
WriteObject(this.VirtualMachineScaleSet);
100111
}
101112
}

src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ public partial class PSVirtualMachineScaleSet
2020
{
2121
// Gets or sets the FQDN.
2222
public string FullyQualifiedDomainName { get; set; }
23+
24+
// Gets or sets the AddProxyAgentExtension.
25+
public bool? AddProxyAgentExtension { get; set; }
26+
2327
}
2428
}

src/Compute/Compute/Manual/PSVirtualMachineScaleSetVMProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ public class PSVirtualMachineScaleSetVMProfile
4141
public PSApplicationProfile ApplicationProfile { get; set; }
4242
public SecurityPostureReference SecurityPostureReference { get; set; }
4343
public System.DateTime? TimeCreated { get; private set; }
44+
public bool? AddProxyAgentExtension { get; set; }
4445
}
4546
}

0 commit comments

Comments
 (0)