Skip to content

Commit a2eea08

Browse files
authored
Merge branch 'preview' into errorfix
2 parents 17af7ab + 1f78e44 commit a2eea08

File tree

106 files changed

+32341
-13092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+32341
-13092
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function Test-VirtualMachineProfile
133133
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
134134
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
135135
Assert-AreEqual $managedOsDiskId_1 $p.StorageProfile.OSDisk.ManagedDisk.Id;
136-
Assert-AreEqual "Standard_LRS" $p.StorageProfile.OSDisk.ManagedDisk.StorageAccountType;
136+
Assert-Null $p.StorageProfile.OSDisk.ManagedDisk.StorageAccountType;
137137
Assert-AreEqual $false $p.StorageProfile.OSDisk.WriteAcceleratorEnabled;
138138

139139
# Windows OS

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,5 +384,17 @@ public void TestVirtualMachineWriteAcceleratorUpdate()
384384
{
385385
ComputeTestController.NewInstance.RunPsTest(_logger, "Test-VirtualMachineWriteAcceleratorUpdate");
386386
}
387+
388+
#if NETSTANDARD
389+
[Fact(Skip = "Updated Storage, needs re-recorded")]
390+
[Trait(Category.RunType, Category.DesktopOnly)]
391+
#else
392+
[Fact]
393+
#endif
394+
[Trait(Category.AcceptanceType, Category.CheckIn)]
395+
public void TestVirtualMachineManagedDisk()
396+
{
397+
ComputeTestController.NewInstance.RunPsTest(_logger, "Test-VirtualMachineManagedDisk");
398+
}
387399
}
388400
}

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

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,4 +3318,132 @@ function Test-VirtualMachineWriteAcceleratorUpdate
33183318
# Cleanup
33193319
Clean-ResourceGroup $rgname
33203320
}
3321+
}
3322+
3323+
function Test-VirtualMachineManagedDisk
3324+
{
3325+
# Setup
3326+
$rgname = Get-ComputeTestResourceName
3327+
3328+
try
3329+
{
3330+
$loc = Get-ComputeVMLocation;
3331+
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
3332+
3333+
# VM Profile & Hardware
3334+
$vmsize = 'Standard_DS1';
3335+
$vmname = 'vm' + $rgname;
3336+
3337+
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
3338+
3339+
# NRP
3340+
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
3341+
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
3342+
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
3343+
$subnetId = $vnet.Subnets[0].Id;
3344+
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
3345+
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
3346+
$pubipId = $pubip.Id;
3347+
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
3348+
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
3349+
$nicId = $nic.Id;
3350+
3351+
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
3352+
3353+
# OS & Image
3354+
$user = "Foo2";
3355+
$password = $PLACEHOLDER;
3356+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
3357+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
3358+
$computerName = 'test';
3359+
3360+
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
3361+
3362+
$imgRef = Get-DefaultCRPImage -loc $loc;
3363+
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
3364+
3365+
# Virtual Machine
3366+
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
3367+
3368+
# Get VM
3369+
$vm = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
3370+
3371+
Assert-NotNull $vm.StorageProfile.OsDisk.ManagedDisk.Id;
3372+
Assert-AreEqual 'Premium_LRS' $vm.StorageProfile.OsDisk.ManagedDisk.StorageAccountType;
3373+
3374+
# Create OS snapshot from the VM
3375+
$snapshotConfig = New-AzureRmSnapshotConfig -SourceUri $vm.Storageprofile.OsDisk.ManagedDisk.Id -Location $loc -CreateOption Copy;
3376+
$snapshotname = "ossnapshot";
3377+
New-AzureRmSnapshot -Snapshot $snapshotConfig -SnapshotName $snapshotname -ResourceGroupName $rgname;
3378+
$snapshot = Get-AzureRmSnapshot -SnapshotName $snapshotname -ResourceGroupName $rgname;
3379+
3380+
Assert-NotNull $snapshot.Id;
3381+
Assert-AreEqual $snapshotname $snapshot.Name;
3382+
Assert-AreEqual 'Standard_LRS' $snapshot.Sku.Name;
3383+
3384+
# Create an OS disk from the snapshot
3385+
$osdiskConfig = New-AzureRmDiskConfig -Location $loc -CreateOption Copy -SourceUri $snapshot.Id;
3386+
$osdiskname = "osdisk";
3387+
New-AzureRmDisk -ResourceGroupName $rgname -DiskName $osdiskname -Disk $osdiskConfig;
3388+
$osdisk = Get-AzureRmDisk -ResourceGroupName $rgname -DiskName $osdiskname;
3389+
3390+
Assert-NotNull $osdisk.Id;
3391+
Assert-AreEqual $osdiskname $osdisk.Name;
3392+
Assert-AreEqual 'Standard_LRS' $osdisk.Sku.Name;
3393+
3394+
# Stop the VM
3395+
Stop-AzureRmVM -ResourceGroupName $rgname -Name $vmname -Force;
3396+
3397+
# Change the OS disk of the VM
3398+
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osdiskname -ManagedDiskId $osdisk.Id;
3399+
3400+
# Create an empty disk
3401+
$datadiskconfig = New-AzureRmDiskConfig -Location $loc -CreateOption Empty -AccountType 'Standard_LRS' -DiskSizeGB 10;
3402+
$datadiskname = "datadisk";
3403+
New-AzureRmDisk -ResourceGroupName $rgname -DiskName $datadiskname -Disk $datadiskconfig;
3404+
$datadisk = Get-AzureRmDisk -ResourceGroupName $rgname -DiskName $datadiskname;
3405+
3406+
Assert-NotNull $datadisk.Id;
3407+
Assert-AreEqual $datadiskname $datadisk.Name;
3408+
Assert-AreEqual 'Standard_LRS' $datadisk.Sku.Name;
3409+
3410+
# Add the disk to the VM
3411+
$vm = Add-AzureRmVMDataDisk -VM $vm -Name $datadiskname -ManagedDiskId $dataDisk.Id -Lun 2 -CreateOption Attach -Caching 'ReadWrite';
3412+
3413+
# Update and start the VM
3414+
Update-AzureRmVM -ResourceGroupName $rgname -VM $vm;
3415+
Start-AzureRmVM -ResourceGroupName $rgname -Name $vmname;
3416+
3417+
# Get the updated VM
3418+
$vm = Get-AzureRmVM -ResourceGroupName $rgname -Name $vmname;
3419+
3420+
Assert-NotNull $vm.VmId;
3421+
Assert-AreEqual $vmname $vm.Name ;
3422+
Assert-AreEqual 1 $vm.NetworkProfile.NetworkInterfaces.Count;
3423+
Assert-AreEqual $nicId $vm.NetworkProfile.NetworkInterfaces[0].Id;
3424+
3425+
Assert-AreEqual $imgRef.Offer $vm.StorageProfile.ImageReference.Offer;
3426+
Assert-AreEqual $imgRef.PublisherName $vm.StorageProfile.ImageReference.Publisher;
3427+
Assert-AreEqual $imgRef.Skus $vm.StorageProfile.ImageReference.Sku;
3428+
Assert-AreEqual $imgRef.Version $vm.StorageProfile.ImageReference.Version;
3429+
3430+
Assert-AreEqual $user $vm.OSProfile.AdminUsername;
3431+
Assert-AreEqual $computerName $vm.OSProfile.ComputerName;
3432+
Assert-AreEqual $vmsize $vm.HardwareProfile.VmSize;
3433+
3434+
Assert-True {$vm.DiagnosticsProfile.BootDiagnostics.Enabled;};
3435+
3436+
Assert-AreEqual "BGInfo" $vm.Extensions[0].VirtualMachineExtensionType;
3437+
Assert-AreEqual "Microsoft.Compute" $vm.Extensions[0].Publisher;
3438+
3439+
Assert-AreEqual $osdisk.Id $vm.StorageProfile.OsDisk.ManagedDisk.Id;
3440+
Assert-AreEqual 'Standard_LRS' $vm.StorageProfile.OsDisk.ManagedDisk.StorageAccountType;
3441+
Assert-AreEqual $datadisk.Id $vm.StorageProfile.DataDisks[0].ManagedDisk.Id;
3442+
Assert-AreEqual 'Standard_LRS' $vm.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType;
3443+
}
3444+
finally
3445+
{
3446+
# Cleanup
3447+
Clean-ResourceGroup $rgname
3448+
}
33213449
}

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

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

src/ResourceManager/Compute/Commands.Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
-->
2121
## Current Release
2222
* Fixed the issue that target is missing in error output.
23+
* Fixed issue with storage account type for VM with managed disk
2324
* Fixed issue with default resource groups not being set.
2425
* Fix AEM Extension cmdlets for other environments, for example Azure China
2526

src/ResourceManager/Compute/Commands.Compute/Common/ComputeClientBaseCmdlet.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Text.RegularExpressions;
1919
using Microsoft.Azure.Commands.Compute.Common;
2020
using Microsoft.Azure.Commands.ResourceManager.Common;
21+
using Microsoft.Azure.Management.Compute.Models;
2122

2223
namespace Microsoft.Azure.Commands.Compute
2324
{
@@ -96,6 +97,28 @@ public static string GetOperationIdFromUrlString(string Url)
9697
Match m = r.Match(Url);
9798
return m.Success ? m.Groups["id"].Value : null;
9899
}
100+
101+
public static ManagedDiskParameters SetManagedDisk(string managedDiskId, string storageAccountType, ManagedDiskParameters managedDisk = null)
102+
{
103+
if (string.IsNullOrWhiteSpace(managedDiskId) && string.IsNullOrWhiteSpace(storageAccountType))
104+
{
105+
return managedDisk;
106+
}
107+
108+
managedDisk = new ManagedDiskParameters();
109+
110+
if (!string.IsNullOrWhiteSpace(managedDiskId))
111+
{
112+
managedDisk.Id = managedDiskId;
113+
}
114+
115+
if (!string.IsNullOrWhiteSpace(storageAccountType))
116+
{
117+
managedDisk.StorageAccountType = storageAccountType;
118+
}
119+
120+
return managedDisk;
121+
}
99122
}
100123
}
101124

src/ResourceManager/Compute/Commands.Compute/Generated/Image/Config/AddAzureRmImageDataDiskCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ private void Run()
110110
vDataDisks.BlobUri = this.MyInvocation.BoundParameters.ContainsKey("BlobUri") ? this.BlobUri : null;
111111
vDataDisks.Caching = this.MyInvocation.BoundParameters.ContainsKey("Caching") ? this.Caching : (CachingTypes?) null;
112112
vDataDisks.DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?) null;
113-
vDataDisks.StorageAccountType = this.MyInvocation.BoundParameters.ContainsKey("StorageAccountType") ? (StorageAccountTypes ?) this.StorageAccountType : null;
113+
if (this.MyInvocation.BoundParameters.ContainsKey("StorageAccountType"))
114+
{
115+
vDataDisks.StorageAccountType = (StorageAccountTypes?) this.StorageAccountType;
116+
}
114117
if (this.MyInvocation.BoundParameters.ContainsKey("SnapshotId"))
115118
{
116119
// Snapshot

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/AddAzureVMDataDiskCommand.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,7 @@ public override void ExecuteCmdlet()
224224
DiskSizeGB = this.DiskSizeInGB,
225225
Lun = this.Lun.GetValueOrDefault(),
226226
CreateOption = this.CreateOption,
227-
ManagedDisk = (this.ManagedDiskId == null && this.StorageAccountType == null)
228-
? null
229-
: new ManagedDiskParameters
230-
{
231-
Id = this.ManagedDiskId,
232-
StorageAccountType = this.StorageAccountType
233-
},
227+
ManagedDisk = SetManagedDisk(this.ManagedDiskId, this.StorageAccountType),
234228
WriteAcceleratorEnabled = this.WriteAccelerator.IsPresent
235229
});
236230

@@ -258,11 +252,7 @@ public override void ExecuteCmdlet()
258252
DiskSizeGB = this.DiskSizeInGB,
259253
Lun = this.Lun.GetValueOrDefault(),
260254
CreateOption = this.CreateOption,
261-
ManagedDisk = new ManagedDiskParameters
262-
{
263-
Id = this.ManagedDiskId,
264-
StorageAccountType = this.StorageAccountType
265-
},
255+
ManagedDisk = SetManagedDisk(this.ManagedDiskId, this.StorageAccountType),
266256
WriteAcceleratorEnabled = this.WriteAccelerator.IsPresent
267257
});
268258

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/NewAzureVMDataDiskCommand.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,7 @@ public override void ExecuteCmdlet()
132132
DiskSizeGB = this.DiskSizeInGB,
133133
Lun = this.Lun,
134134
CreateOption = this.CreateOption,
135-
ManagedDisk = (this.ManagedDiskId == null && this.StorageAccountType == null)
136-
? null
137-
: new ManagedDiskParameters
138-
{
139-
Id = this.ManagedDiskId,
140-
StorageAccountType = this.StorageAccountType
141-
},
135+
ManagedDisk = SetManagedDisk(this.ManagedDiskId, this.StorageAccountType),
142136
WriteAcceleratorEnabled = this.WriteAccelerator.IsPresent
143137
};
144138

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMOSDiskCommand.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace Microsoft.Azure.Commands.Compute
2323
{
2424
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMOSDisk",DefaultParameterSetName = DefaultParamSet),OutputType(typeof(PSVirtualMachine))]
25-
public class SetAzureVMOSDiskCommand : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet
25+
public class SetAzureVMOSDiskCommand : ComputeClientBaseCmdlet
2626
{
2727
protected const string DefaultParamSet = "DefaultParamSet";
2828
protected const string WindowsParamSet = "WindowsParamSet";
@@ -244,16 +244,7 @@ public override void ExecuteCmdlet()
244244
};
245245
}
246246

247-
if (!string.IsNullOrEmpty(this.ManagedDiskId) || this.StorageAccountType != null)
248-
{
249-
if (this.VM.StorageProfile.OsDisk.ManagedDisk == null)
250-
{
251-
this.VM.StorageProfile.OsDisk.ManagedDisk = new ManagedDiskParameters();
252-
}
253-
254-
this.VM.StorageProfile.OsDisk.ManagedDisk.Id = this.ManagedDiskId ?? this.VM.StorageProfile.OsDisk.ManagedDisk.Id;
255-
this.VM.StorageProfile.OsDisk.ManagedDisk.StorageAccountType = this.StorageAccountType ?? this.VM.StorageProfile.OsDisk.ManagedDisk.StorageAccountType;
256-
}
247+
this.VM.StorageProfile.OsDisk.ManagedDisk = SetManagedDisk(this.ManagedDiskId, this.StorageAccountType, this.VM.StorageProfile.OsDisk.ManagedDisk);
257248

258249
this.VM.StorageProfile.OsDisk.WriteAcceleratorEnabled = this.WriteAccelerator.IsPresent;
259250

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/DRConfigurationTests.ps1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ function DRConfigurationTests
9494
# Assert
9595
Assert-AreEqual $result2.Name $namespaceName2
9696

97-
Try
98-
{
99-
# get the created Eventhub Namespace 1
97+
# get the created Eventhub Namespace 1
10098
Write-Debug " Get the created namespace within the resource group"
10199
$createdNamespace1 = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName1
102100

@@ -267,10 +265,7 @@ function DRConfigurationTests
267265

268266
# Assert
269267
Assert-AreEqual $createdServiceBusDRConfigList_delete.Count 0 "DR Config List: after delete the DRCoinfig was listed"
270-
}
271-
Finally
272-
{
273-
# Wait till the Namespace Provisioning state changes to succeeded
268+
# Wait till the Namespace Provisioning state changes to succeeded
274269
WaitforStatetoBeSucceded_namespace $resourceGroupName $namespaceName1
275270

276271
Write-Debug " Delete namespaces"
@@ -284,7 +279,6 @@ function DRConfigurationTests
284279

285280
Write-Debug " Delete resourcegroup"
286281
Remove-AzureRmResourceGroup -Name $resourceGroupName -Force
287-
}
288282
}
289283

290284
function DRConfigurationTestsAlternateName

src/ResourceManager/EventHub/Commands.EventHub.Test/SessionRecords/Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.ConsumerGroupsTests/ConsumerGroupsCRUD.json

Lines changed: 341 additions & 263 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)