Skip to content

Commit 7df2344

Browse files
committed
Fix the following issues:
1. Null exception issue for Get-AzRemoteDesktopFile 2. UltraSSD issue for New-AzVM and Update-AzVM 3. VHD seek stream issue
1 parent 968199f commit 7df2344

File tree

8 files changed

+5931
-4
lines changed

8 files changed

+5931
-4
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,12 @@ public void TestVirtualMachineStop()
262262
{
263263
TestRunner.RunTestScript("Test-VirtualMachineStop");
264264
}
265+
266+
[Fact]
267+
[Trait(Category.AcceptanceType, Category.CheckIn)]
268+
public void TestVirtualMachineRemoteDesktop()
269+
{
270+
TestRunner.RunTestScript("Test-VirtualMachineRemoteDesktop");
271+
}
265272
}
266273
}

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3632,3 +3632,83 @@ function Test-VirtualMachineStop
36323632
Clean-ResourceGroup $rgname
36333633
}
36343634
}
3635+
3636+
<#
3637+
.SYNOPSIS
3638+
Test Virtual Machine Managed Disk
3639+
#>
3640+
function Test-VirtualMachineRemoteDesktop
3641+
{
3642+
# Setup
3643+
$rgname = Get-ComputeTestResourceName
3644+
3645+
try
3646+
{
3647+
$loc = Get-ComputeVMLocation;
3648+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
3649+
3650+
# VM Profile & Hardware
3651+
$vmsize = 'Standard_DS2_v2';
3652+
$vmname = 'vm' + $rgname;
3653+
3654+
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize -EnableUltraSSD -Zone "1";
3655+
3656+
# NRP
3657+
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
3658+
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
3659+
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
3660+
$subnetId = $vnet.Subnets[0].Id;
3661+
$nic = New-AzNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId
3662+
$nic = Get-AzNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
3663+
$nicId = $nic.Id;
3664+
3665+
$p = Add-AzVMNetworkInterface -VM $p -Id $nicId;
3666+
3667+
# OS & Image
3668+
$user = "Foo2";
3669+
$password = $PLACEHOLDER;
3670+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
3671+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
3672+
$computerName = 'test';
3673+
3674+
$p = Set-AzVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
3675+
3676+
$imgRef = Get-DefaultCRPImage -loc $loc;
3677+
$p = ($imgRef | Set-AzVMSourceImage -VM $p);
3678+
3679+
# Virtual Machine
3680+
Assert-ThrowsContains { `
3681+
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p; } `
3682+
"'Microsoft.Compute/UltraSSD' feature is not enabled for this subscription.";
3683+
3684+
$p.AdditionalCapabilities.UltraSSDEnabled = $false;
3685+
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p;
3686+
3687+
# Get VM
3688+
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
3689+
Assert-False {$vm.AdditionalCapabilities.UltraSSDEnabled};
3690+
$vmstate = Get-AzVM -ResourceGroupName $rgname -Name $vmname -Status;
3691+
3692+
Assert-ThrowsContains { `
3693+
Get-AzRemoteDesktopFile -ResourceGroupName $rgname -Name $vmname -LocalPath ".\file.rdp"; } `
3694+
"The RDP file cannot be generated because the network interface of the virtual machine does not reference a PublicIP or an InboundNatRule of a public load balancer.";
3695+
3696+
$pubip = New-AzPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -Zone "1" -Sku "Standard" -AllocationMethod "Static" -DomainNameLabel ('pubip' + $rgname);
3697+
$pubip = Get-AzPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
3698+
$pubipId = $pubip.Id;
3699+
3700+
$nic = Get-AzNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
3701+
$nic | Set-AzNetworkInterfaceIpConfig -Name 'ipconfig1' -SubnetId $subnetId -PublicIpAddressId $pubip.Id | Set-AzNetworkInterface;
3702+
3703+
# Get VM
3704+
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
3705+
$vmstate = Get-AzVM -ResourceGroupName $rgname -Name $vmname -Status;
3706+
3707+
Get-AzRemoteDesktopFile -ResourceGroupName $rgname -Name $vmname -LocalPath ".\file.rdp";
3708+
}
3709+
finally
3710+
{
3711+
# Cleanup
3712+
Clean-ResourceGroup $rgname
3713+
}
3714+
}

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

Lines changed: 5835 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
@@ -19,6 +19,9 @@
1919
- Additional information about change #1
2020
-->
2121
## Upcoming Release
22+
* Fix the null exception for Get-AzRemoteDesktopFile.
23+
* Fix VHD Seek method for end-relative position.
24+
* Fix UltraSSD issue for New-AzVM and Update-AzVM.
2225

2326
## Version 2.5.0
2427
* Add VmssId to New-AzVMConfig cmdlet

src/Compute/Compute/RemoteDesktop/GetAzureRemoteDesktopFileCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public override void ExecuteCmdlet()
106106
// Get PublicIPAddress resource if present
107107
address = this.GetAddressFromPublicIPResource(nic.IpConfigurations.First().PublicIPAddress.Id);
108108
}
109-
else if (nic.IpConfigurations.First().LoadBalancerInboundNatRules.Any())
109+
else if (nic.IpConfigurations.First().LoadBalancerInboundNatRules != null && nic.IpConfigurations.First().LoadBalancerInboundNatRules.Any())
110110
{
111111
address = string.Empty;
112112

src/Compute/Compute/VhdManagement/VirtualDiskStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public override long Seek(long offset, SeekOrigin origin)
224224
this.Position += offset;
225225
break;
226226
case SeekOrigin.End:
227-
this.Position -= offset;
227+
this.Position = this.Length + offset;
228228
break;
229229
default:
230230
throw new NotSupportedException();

src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@ public void DefaultExecuteCmdlet()
535535
Zones = this.Zone ?? this.VM.Zones,
536536
ProximityPlacementGroup = this.VM.ProximityPlacementGroup,
537537
Host = this.VM.Host,
538-
VirtualMachineScaleSet = this.VM.VirtualMachineScaleSet
538+
VirtualMachineScaleSet = this.VM.VirtualMachineScaleSet,
539+
AdditionalCapabilities = this.VM.AdditionalCapabilities
539540
};
540541

541542
Dictionary<string, List<string>> auxAuthHeader = null;

src/Compute/Compute/VirtualMachine/Operation/UpdateAzureVMCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public override void ExecuteCmdlet()
139139
Zones = (this.VM.Zones != null && this.VM.Zones.Count > 0) ? this.VM.Zones : null,
140140
ProximityPlacementGroup = this.VM.ProximityPlacementGroup,
141141
Host = this.VM.Host,
142-
VirtualMachineScaleSet = this.VM.VirtualMachineScaleSet
142+
VirtualMachineScaleSet = this.VM.VirtualMachineScaleSet,
143+
AdditionalCapabilities = this.VM.AdditionalCapabilities
143144
};
144145

145146
if (this.IsParameterBound(c => c.IdentityType))

0 commit comments

Comments
 (0)