Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,12 @@ public void TestProxyAgentSetting()
{
TestRunner.RunTestScript("Test-ProxyAgentSetting");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineScaleSetAddProxyAgentExtension()
{
TestRunner.RunTestScript("Test-VirtualMachineScaleSetAddProxyAgentExtension");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5965,4 +5965,54 @@ function Test-ProxyAgentSetting
# Cleanup
Clean-ResourceGroup $rgname;
}
}

<#
.SYNOPSIS
Test-VirtualMachineScaleSetAddProxyAgentExtension creates a VMSS with Enabled ProxyAgent and added ProxyAgentExtension
#>
function Test-VirtualMachineScaleSetAddProxyAgentExtension
{
# Setup
$rgname = Get-ComputeTestResourceName;
$loc = "eastus2";


try
{
# Common
New-AzResourceGroup -Name $rgname -Location $loc -Force;

$vmssName = 'vmss' + $rgname;
$domainNameLabel1 = "d1" + $rgname;

$adminUsername = Get-ComputeTestResourceName;
$password = Get-PasswordForVM;
$adminPassword = $password | ConvertTo-SecureString -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword);
$linuxImage = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest"

# Case 1: Create using simple parameter set
$vmss = New-AzVmss -ResourceGroupName $rgname -Location $loc -Credential $cred -VMScaleSetName $vmssName -DomainNameLabel $domainNameLabel1 -Image $linuxImage -EnableProxyAgent -AddProxyAgentExtension

# verify
Assert-AreEqual $vmss.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.Enabled $true


# Update vmss to add proxy agent extension
$VMSS = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName
$VMSS = Set-AzVmssProxyAgentSetting -VirtualMachineScaleSet $VMSS -EnableProxyAgent $true -AddProxyAgentExtension $true
$vmssUpdated = Update-AzVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $VMSS



# Validate
Assert-AreEqual $vmssUpdated.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.Enabled $true
Assert-AreEqual $vmssUpdated.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension $true
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,19 @@ public void TestEncryptionIdentityNotPartOfAssignedIdentitiesInAzureVm()
{
TestRunner.RunTestScript("Test-EncryptionIdentityNotPartOfAssignedIdentitiesInAzureVm");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachinePlacement()
{
TestRunner.RunTestScript("Test-VirtualMachinePlacement");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineAddProxyAgentExtension()
{
TestRunner.RunTestScript("Test-VirtualMachineAddProxyAgentExtension");
}
}
}
40 changes: 38 additions & 2 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7915,7 +7915,7 @@ function Test-VirtualMachinePlacement
$user = Get-ComputeTestResourceName;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);

# create VM with placement feature
# create VM with placement feature
$vmname = '1' + $rgname;
$domainNameLabel = "d1" + $rgname;
$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -Image CentOS85Gen2 -DomainNameLabel $domainNameLabel -ZonePlacementPolicy "Any" -IncludeZone "1","2" -AlignRegionalDisksToVMZone
Expand All @@ -7938,4 +7938,40 @@ function Test-VirtualMachinePlacement
# Cleanup
Clean-ResourceGroup $rgname;
}
}
}

<#
.SYNOPSIS
Test-VirtualMachineAddProxyAgentExtension creates a VM with Enabled ProxyAgent and added ProxyAgentExtension
#>
function Test-VirtualMachineAddProxyAgentExtension
{
# Setup
$resourceGroupName = Get-ComputeTestResourceName;
$adminUsername = Get-ComputeTestResourceName;
$adminPassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword);
$vmName = 'VM1';
$imageName = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest";
$domainNameLabel = "d1" + $resourceGroupName;


try
{
New-AzVM -ResourceGroupName $resourceGroupName -Name $VMName -Credential $cred -image $imageName -DomainNameLabel $domainNameLabel -Location 'eastus2' -EnableProxyAgent -AddProxyAgentExtension

# Update vm to add proxy agent extension
$VM = Get-AzVM -ResourceGroupName $resourceGroupName -VMName $vmName
$VM = Set-AzVMProxyAgentSetting -VM $VM -EnableProxyAgent $true -AddProxyAgentExtension $false
Update-AzVM -ResourceGroupName $resourceGroupName -VM $VM

# Validate
Assert-AreEqual $VM.SecurityProfile.ProxyAgentSettings.Enabled $true
Assert-AreEqual $VM.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension $false
}
finally
{
# Cleanup
Clean-ResourceGroup $resourceGroupName;
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
-->
## Upcoming Release
* Added `-Redeploy` switch parameter for `Update-AzHost` cmdlet to enable dedicated host redeployment.
* ComputeRP related cmdlets will now use 2025-04-01 version of the ComputeRP API.
* Added `-AddProxyAgentExtension` parameter (Switch) to `New-AzVmss` and `New-AzVM`
* Added `-AddProxyAgentExtension` parameter (Bool) to `Set-AzVMProxyAgentSetting` and `Set-AzVmssProxyAgentSetting`

## Version 10.4.0
* Added `-InstantAccessDurationMinutes` parameter to New-AzSnapshotConfig.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public class SetAzureVmssProxySetting : Microsoft.Azure.Commands.ResourceManager
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}")]
public string ImdsProfile { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies whether to add installation of the ProxyAgent extension.")]
public bool? AddProxyAgentExtension { get; set; }

public override void ExecuteCmdlet()
{
if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
Expand Down Expand Up @@ -96,6 +102,11 @@ public override void ExecuteCmdlet()
})
};

if (this.MyInvocation.BoundParameters.ContainsKey(nameof(AddProxyAgentExtension)))
{
this.VirtualMachineScaleSet.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension = this.AddProxyAgentExtension;
}

WriteObject(this.VirtualMachineScaleSet);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public partial class PSVirtualMachineScaleSet
{
// Gets or sets the FQDN.
public string FullyQualifiedDomainName { get; set; }

// Gets or sets the AddProxyAgentExtension.
public bool? AddProxyAgentExtension { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ public class PSVirtualMachineScaleSetVMProfile
public PSApplicationProfile ApplicationProfile { get; set; }
public SecurityPostureReference SecurityPostureReference { get; set; }
public System.DateTime? TimeCreated { get; private set; }
public bool? AddProxyAgentExtension { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ public partial class NewAzureRmVmss : ComputeAutomationBaseCmdlet
HelpMessage = "Specifies whether Metadata Security Protocol(ProxyAgent) feature should be enabled or not.")]
public SwitchParameter EnableProxyAgent { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
ParameterSetName = SimpleParameterSet,
HelpMessage = "Specifies whether to add installation of the ProxyAgent extension.")]
public SwitchParameter AddProxyAgentExtension { get; set; }

private void ConfigureSecuritySettings()
{
if (SecurityType?.ToLower() == SecurityTypes.TrustedLaunch ||
Expand Down Expand Up @@ -552,7 +559,8 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetNor
ifNoneMatch: _cmdlet.IfNoneMatch,
securityPostureId: _cmdlet.SecurityPostureId,
securityPostureExcludeExtension: _cmdlet.SecurityPostureExcludeExtension,
enableProxyAgent: _cmdlet.EnableProxyAgent ? true : (bool?)null
enableProxyAgent: _cmdlet.EnableProxyAgent ? true : (bool?)null,
addProxyAgentExtension: _cmdlet.AddProxyAgentExtension.IsPresent ? true : (bool?)null
);
}

Expand Down Expand Up @@ -692,7 +700,8 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrc
ifNoneMatch: _cmdlet.IfNoneMatch,
securityPostureId: _cmdlet.SecurityPostureId,
securityPostureExcludeExtension: _cmdlet.SecurityPostureExcludeExtension,
enableProxyAgent: _cmdlet.EnableProxyAgent ? true : (bool?)null
enableProxyAgent: _cmdlet.EnableProxyAgent ? true : (bool?)null,
addProxyAgentExtension: _cmdlet.AddProxyAgentExtension.IsPresent ? true : (bool?)null
);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Compute/Compute/Models/PSVirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,8 @@ public string ResourceGroupName
public string Etag { get; private set; }

public Placement Placement { get; set; }

// Gets or sets the AddProxyAgentExtension
public bool? AddProxyAgentExtension { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
string ifNoneMatch = null,
string securityPostureId = null,
string[] securityPostureExcludeExtension = null,
bool? enableProxyAgent = null
bool? enableProxyAgent = null,
bool? addProxyAgentExtension = null
)
=> Strategy.CreateResourceConfig(
resourceGroup: resourceGroup,
Expand Down Expand Up @@ -114,7 +115,7 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
EncryptionAtHost = encryptionAtHost,
UefiSettings = (enableVtpm != null || enableSecureBoot != null) ? new UefiSettings(enableSecureBoot, enableVtpm) : null,
SecurityType = securityType,
ProxyAgentSettings = enableProxyAgent == true ? new ProxyAgentSettings(enableProxyAgent) : null
ProxyAgentSettings = (enableProxyAgent != null || addProxyAgentExtension != null) ? new ProxyAgentSettings(enableProxyAgent) { AddProxyAgentExtension = addProxyAgentExtension } : null,
},
OsProfile = new VirtualMachineScaleSetOSProfile
{
Expand Down Expand Up @@ -252,7 +253,8 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
string ifNoneMatch = null,
string securityPostureId = null,
string[] securityPostureExcludeExtension = null,
bool? enableProxyAgent = null
bool? enableProxyAgent = null,
bool? addProxyAgentExtension = null
)
=> Strategy.CreateResourceConfig(
resourceGroup: resourceGroup,
Expand Down Expand Up @@ -285,7 +287,7 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
EncryptionAtHost = encryptionAtHost,
UefiSettings = (enableVtpm != null || enableSecureBoot != null) ? new UefiSettings(enableSecureBoot, enableVtpm) : null,
SecurityType = securityType,
ProxyAgentSettings = enableProxyAgent == true ? new ProxyAgentSettings(enableProxyAgent) : null
ProxyAgentSettings = (enableProxyAgent != null || addProxyAgentExtension != null) ? new ProxyAgentSettings(enableProxyAgent) { AddProxyAgentExtension = addProxyAgentExtension } : null,
},
OsProfile = new VirtualMachineScaleSetOSProfile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
string[] includeZone = null,
string[] excludeZone = null,
bool? alignRegionalDisksToVMZone = null,
bool? enableProxyAgent = null
bool? enableProxyAgent = null,
bool? addProxyAgentExtension = null
)
=> Strategy.CreateResourceConfig(
resourceGroup: resourceGroup,
Expand Down Expand Up @@ -163,7 +164,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
EncryptionAtHost = encryptionAtHostPresent,
UefiSettings = (enableVtpm != null || enableSecureBoot != null) ? new UefiSettings(enableSecureBoot, enableVtpm) : null,
SecurityType = securityType,
ProxyAgentSettings = enableProxyAgent == true ? new ProxyAgentSettings(enableProxyAgent) : null,
ProxyAgentSettings = (enableProxyAgent != null || addProxyAgentExtension != null) ? new ProxyAgentSettings(enableProxyAgent) { AddProxyAgentExtension = addProxyAgentExtension } : null,
},
CapacityReservation = string.IsNullOrEmpty(capacityReservationGroupId) ? null : new CapacityReservationProfile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public class SetAzureVMProxySetting : Microsoft.Azure.Commands.ResourceManager.C
HelpMessage = "Increase the value of this parameter allows users to reset the key used for securing communication channel between guest and host.")]
public int? KeyIncarnationId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies whether to add installation of the ProxyAgent extension.")]
public bool? AddProxyAgentExtension { get; set; }

public override void ExecuteCmdlet()
{
if (this.VM.SecurityProfile == null)
Expand All @@ -95,6 +101,11 @@ public override void ExecuteCmdlet()
KeyIncarnationId = this.KeyIncarnationId
};

if (this.MyInvocation.BoundParameters.ContainsKey(nameof(AddProxyAgentExtension)))
{
this.VM.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension = this.AddProxyAgentExtension;
}

WriteObject(this.VM);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,13 @@ public class NewAzureVMCommand : VirtualMachineBaseCmdlet
HelpMessage = "Specifies whether Metadata Security Protocol(ProxyAgent) feature should be enabled or not.")]
public SwitchParameter EnableProxyAgent { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
ParameterSetName = SimpleParameterSet,
HelpMessage = "Specifies whether to add installation of the ProxyAgent extension.")]
public SwitchParameter AddProxyAgentExtension { get; set; }

public override void ExecuteCmdlet()
{

Expand Down Expand Up @@ -749,7 +756,8 @@ public async Task<ResourceConfig<VirtualMachine>> CreateConfigAsync()
includeZone: _cmdlet.IncludeZone,
excludeZone: _cmdlet.ExcludeZone,
alignRegionalDisksToVMZone: _cmdlet.AlignRegionalDisksToVMZone,
enableProxyAgent: _cmdlet.EnableProxyAgent ? true : (bool?)null
enableProxyAgent: _cmdlet.EnableProxyAgent ? true : (bool?)null,
addProxyAgentExtension: _cmdlet.AddProxyAgentExtension ? true : (bool?)null
);
}
else // does not get used. DiskFile parameter set is not supported.
Expand Down
17 changes: 16 additions & 1 deletion src/Compute/Compute/help/New-AzVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ New-AzVM [[-ResourceGroupName] <String>] [[-Location] <String>] [-EdgeZone <Stri
[-SharedGalleryImageId <String>] [-SecurityType <String>] [-EnableVtpm <Boolean>]
[-EnableSecureBoot <Boolean>] [-IfMatch <String>] [-IfNoneMatch <String>] [-SshKeyType <String>]
[-ZonePlacementPolicy <String>] [-IncludeZone <String[]>] [-ExcludeZone <String[]>]
[-AlignRegionalDisksToVMZone] [-EnableProxyAgent] [-DefaultProfile <IAzureContextContainer>]
[-AlignRegionalDisksToVMZone] [-EnableProxyAgent] [-AddProxyAgentExtension] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

Expand Down Expand Up @@ -633,6 +633,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -AddProxyAgentExtension
Specifies whether to implicitly install the ProxyAgent Extension. This option is currently applicable only for Linux OS.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: SimpleParameterSet
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -EnableSecureBoot
Specifies whether secure boot should be enabled on the virtual machine.

Expand Down
Loading