Skip to content

Commit 079fd4a

Browse files
authored
Merge pull request #5842 from cormacpayne/compute-fix
Merge AzureRM.Compute.4.6.0 branch into preview
2 parents 4a0f250 + 5ceae56 commit 079fd4a

File tree

293 files changed

+3002
-2058
lines changed

Some content is hidden

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

293 files changed

+3002
-2058
lines changed

src/ResourceManager/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Update for Zone Resilient
2122
* `New-AzureRmVm` and `New-AzureRmVmss` (simple parameter set) support availability zones.
2223
* Updated to the latest version of the Azure ClientRuntime
2324

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Compute">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.17.5.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.18.0.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.Management.Network, Version=17.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7070
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.17.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Test-Disk
5252
$diskconfig.EncryptionSettings.DiskEncryptionKey = $null;
5353
$diskconfig.EncryptionSettings.KeyEncryptionKey = $null;
5454
$diskconfig.CreationData.ImageReference = $null;
55-
55+
5656
Assert-AreEqual "1" $diskconfig.Zones
5757
$diskconfig.Zones = $null
5858

@@ -64,7 +64,7 @@ function Test-Disk
6464
$disk = Get-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname;
6565
Assert-AreEqual $null $disk.Zones;
6666
Assert-AreEqual 5 $disk.DiskSizeGB;
67-
Assert-AreEqual StandardLRS $disk.Sku.Name;
67+
Assert-AreEqual "StandardLRS" $disk.Sku.Name;
6868
Assert-AreEqual Windows $disk.OsType;
6969
Assert-AreEqual Empty $disk.CreationData.CreateOption;
7070
Assert-AreEqual $false $disk.EncryptionSettings.Enabled;
@@ -139,7 +139,7 @@ function Test-Snapshot
139139
# Get snapshot test
140140
$snapshot = Get-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname;
141141
Assert-AreEqual 5 $snapshot.DiskSizeGB;
142-
Assert-AreEqual StandardLRS $snapshot.Sku.Name;
142+
Assert-AreEqual "StandardLRS" $snapshot.Sku.Name;
143143
Assert-AreEqual Windows $snapshot.OsType;
144144
Assert-AreEqual Empty $snapshot.CreationData.CreateOption;
145145
Assert-AreEqual $false $snapshot.EncryptionSettings.Enabled;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Test-VirtualMachineProfile
4545
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $ipRefUri1 -Primary;
4646
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $ipRefUri2;
4747
$p = Remove-AzureRmVMNetworkInterface -VM $p -Id $ipRefUri2;
48-
48+
4949
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
5050
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $ipRefUri1;
5151
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Primary $true;
@@ -121,15 +121,15 @@ function Test-VirtualMachineProfile
121121
Assert-AreEqual $osDiskName $p.StorageProfile.OSDisk.Name;
122122
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
123123
Assert-AreEqual $managedOsDiskId_0 $p.StorageProfile.OSDisk.ManagedDisk.Id;
124-
Assert-AreEqual 'StandardLRS' $p.StorageProfile.OSDisk.ManagedDisk.StorageAccountType;
124+
Assert-AreEqual "StandardLRS" $p.StorageProfile.OSDisk.ManagedDisk.StorageAccountType;
125125
Assert-AreEqual $true $p.StorageProfile.OSDisk.WriteAcceleratorEnabled;
126126

127127
$p = Set-AzureRmVMOsDisk -VM $p -ManagedDiskId $managedOsDiskId_1;
128128
Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
129129
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
130130
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
131131
Assert-AreEqual $managedOsDiskId_1 $p.StorageProfile.OSDisk.ManagedDisk.Id;
132-
Assert-AreEqual 'StandardLRS' $p.StorageProfile.OSDisk.ManagedDisk.StorageAccountType;
132+
Assert-AreEqual "StandardLRS" $p.StorageProfile.OSDisk.ManagedDisk.StorageAccountType;
133133
Assert-AreEqual $false $p.StorageProfile.OSDisk.WriteAcceleratorEnabled;
134134

135135
# Windows OS

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function Test-VirtualMachineScaleSet-Common($IsManaged)
145145
Assert-AreEqual 20 $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].DiskSizeGB;
146146
Assert-AreEqual 1 $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].Lun;
147147
Assert-AreEqual 'Empty' $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].CreateOption;
148-
Assert-AreEqual 'StandardLRS' $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType;
148+
Assert-AreEqual "StandardLRS" $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType;
149149
Assert-AreEqual $true $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].WriteAcceleratorEnabled;
150150
$vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].WriteAcceleratorEnabled = $false;
151151

@@ -353,12 +353,12 @@ function Test-VirtualMachineScaleSetUpdate
353353

354354
$imgRef = Get-DefaultCRPImage -loc $loc;
355355
$vhdContainer = "https://" + $stoname + ".blob.core.windows.net/" + $vmssName;
356-
356+
357357
$extname = 'csetest';
358358
$publisher = 'Microsoft.Compute';
359359
$exttype = 'BGInfo';
360360
$extver = '2.1';
361-
361+
362362
$ipCfg = New-AzureRmVmssIPConfig -Name 'test' -SubnetId $subnetId;
363363
$vmss = New-AzureRmVmssConfig -Location $loc -SkuCapacity 2 -SkuName 'Standard_A0' -UpgradePolicyMode 'Manual' `
364364
| Add-AzureRmVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg `
@@ -402,7 +402,7 @@ function Test-VirtualMachineScaleSetUpdate
402402
Assert-AreEqual $exttype $result.VirtualMachineProfile.ExtensionProfile.Extensions[0].Type;
403403
Assert-AreEqual $extver $result.VirtualMachineProfile.ExtensionProfile.Extensions[0].TypeHandlerVersion;
404404
Assert-AreEqual $true $result.VirtualMachineProfile.ExtensionProfile.Extensions[0].AutoUpgradeMinorVersion;
405-
405+
406406
# Verify the result of VMSS
407407
$vmss = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
408408
Assert-AreEqual $null $vmss.Zones;
@@ -1283,7 +1283,7 @@ function Test-VirtualMachineScaleSetRollingUpgrade
12831283
$result = $job | Wait-Job;
12841284
Assert-AreEqual "Failed" $result.State;
12851285
Assert-True { $result.Error[0].ToString().Contains("InternalExecutionError")};
1286-
1286+
12871287
$job = Stop-AzureRmVmssRollingUpgrade -ResourceGroupName $rgname -VMScaleSetName $vmssName -Force -AsJob;
12881288
$result = $job | Wait-Job;
12891289
Assert-AreEqual "Failed" $result.State;
@@ -1444,7 +1444,7 @@ function Test-VirtualMachineScaleSetWriteAcceleratorUpdate
14441444
Assert-AreEqual $exttype $result.VirtualMachineProfile.ExtensionProfile.Extensions[0].Type;
14451445
Assert-AreEqual $extver $result.VirtualMachineProfile.ExtensionProfile.Extensions[0].TypeHandlerVersion;
14461446
Assert-AreEqual $true $result.VirtualMachineProfile.ExtensionProfile.Extensions[0].AutoUpgradeMinorVersion;
1447-
1447+
14481448
# Verify the result of VMSS
14491449
$vmss = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
14501450
Assert-AreEqual $null $vmss.Zones;

src/ResourceManager/Compute/Commands.Compute.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Graph.RBAC" version="3.4.0-preview" targetFramework="net452" />
88
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.Compute" version="17.5.0" targetFramework="net452" />
9+
<package id="Microsoft.Azure.Management.Compute" version="18.0.0" targetFramework="net452" />
1010
<package id="Microsoft.Azure.Management.Network" version="17.0.0-preview" targetFramework="net452" />
1111
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.Netcore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<ItemGroup >
3030
<PackageReference Include="AutoMapper" Version="6.0.2" />
31-
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="17.5.0" />
31+
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="18.0.0" />
3232
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.3.0-preview" />
3333
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" />
3434
</ItemGroup>

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<Private>True</Private>
5454
</Reference>
5555
<Reference Include="Microsoft.Azure.Management.Compute">
56-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.17.5.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
56+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.18.0.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
5757
<Private>True</Private>
5858
</Reference>
5959
<Reference Include="Microsoft.Azure.Management.KeyVault, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -128,6 +128,7 @@
128128
<Compile Include="Common\ComputeClientInstancViewMethod.cs" />
129129
<Compile Include="Common\ComputeCloudException.cs" />
130130
<Compile Include="Common\DiagnosticsHelper.cs" />
131+
<Compile Include="Common\StorageAccountTypesExtensions.cs" />
131132
<Compile Include="Common\StorageManagementClient.cs" />
132133
<Compile Include="ExtensionImages\GetAzureVMExtensionImageTypeCommand.cs" />
133134
<Compile Include="ExtensionImages\GetAzureVMExtensionImageCommand.cs" />
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Management.Compute.Models;
16+
using System;
17+
using System.Collections.Generic;
18+
using System.Text;
19+
20+
namespace Microsoft.Azure.Commands.Compute.Common
21+
{
22+
public static class StorageAccountTypesExtensions
23+
{
24+
private static string StandardLRS = "StandardLRS";
25+
private static string StandardZRS = "StandardZRS";
26+
private static string PremiumLRS = "PremiumLRS";
27+
28+
private static string Standard_LRS = "Standard_LRS";
29+
private static string Standard_ZRS = "Standard_ZRS";
30+
private static string Premium_LRS = "Premium_LRS";
31+
32+
private static Dictionary<string, string> _toSerializedMappings = new Dictionary<string, string>()
33+
{
34+
{ StandardLRS, Standard_LRS },
35+
{ StandardZRS, Standard_ZRS },
36+
{ PremiumLRS, Premium_LRS }
37+
};
38+
39+
private static Dictionary<string, string> _toUnserializedMappings = new Dictionary<string, string>()
40+
{
41+
{ Standard_LRS, StandardLRS },
42+
{ Standard_ZRS, StandardZRS },
43+
{ Premium_LRS, PremiumLRS }
44+
};
45+
46+
public static string ToSerializedValue(this string storageAccountType)
47+
{
48+
if (!string.IsNullOrEmpty(storageAccountType) && _toSerializedMappings.ContainsKey(storageAccountType))
49+
{
50+
return _toSerializedMappings[storageAccountType];
51+
}
52+
53+
return storageAccountType;
54+
}
55+
56+
public static string ToUnserializedValue(this string storageAccountType)
57+
{
58+
if (!string.IsNullOrEmpty(storageAccountType) && _toUnserializedMappings.ContainsKey(storageAccountType))
59+
{
60+
return _toUnserializedMappings[storageAccountType];
61+
}
62+
63+
return storageAccountType;
64+
}
65+
66+
public static StorageProfile ToSerializedStorageProfile(this StorageProfile storageProfile)
67+
{
68+
if (storageProfile != null &&
69+
storageProfile.DataDisks != null)
70+
{
71+
foreach (var disk in storageProfile.DataDisks)
72+
{
73+
if (disk != null && disk.ManagedDisk != null)
74+
{
75+
disk.ManagedDisk.StorageAccountType = disk.ManagedDisk.StorageAccountType.ToSerializedValue();
76+
}
77+
}
78+
}
79+
80+
return storageProfile;
81+
}
82+
83+
public static StorageProfile ToUnserializedStorageProfile(this StorageProfile storageProfile)
84+
{
85+
if (storageProfile != null &&
86+
storageProfile.DataDisks != null)
87+
{
88+
foreach (var disk in storageProfile.DataDisks)
89+
{
90+
if (disk != null && disk.ManagedDisk != null)
91+
{
92+
disk.ManagedDisk.StorageAccountType = disk.ManagedDisk.StorageAccountType.ToUnserializedValue();
93+
}
94+
}
95+
}
96+
97+
return storageProfile;
98+
}
99+
}
100+
}

src/ResourceManager/Compute/Commands.Compute/Extension/VmssDiskEncryption/DisableAzureVmssDiskEncryption.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public override void ExecuteCmdlet()
8787

8888
ExecuteClientAction(() =>
8989
{
90+
WriteWarning("Disable-AzureRmVmssDiskEncryption: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
91+
"The StorageAccountType property for a DataDisk will return Standard_LRS and Premium_LRS");
92+
9093
if (this.ShouldProcess(VMScaleSetName, Properties.Resources.RemoveDiskEncryptionAction)
9194
&& (this.Force.IsPresent
9295
|| this.ShouldContinue(Properties.Resources.VirtualMachineExtensionRemovalConfirmation, Properties.Resources.VirtualMachineExtensionRemovalCaption)))

src/ResourceManager/Compute/Commands.Compute/Extension/VmssDiskEncryption/SetAzureVmssDiskEncryptionExtension.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private VirtualMachineScaleSetExtension GetVmssExtensionParameters()
182182
{
183183
Hashtable SettingString = GetExtensionPublicSettings();
184184
Hashtable ProtectedSettingString = GetExtensionProtectedSettings();
185-
185+
186186
VirtualMachineScaleSetExtension vmssExtensionParameters = null;
187187

188188
if (OperatingSystemTypes.Windows.Equals(this.CurrentOSType))
@@ -229,6 +229,9 @@ public override void ExecuteCmdlet()
229229

230230
ExecuteClientAction(() =>
231231
{
232+
WriteWarning("Set-AzureRmVmssDiskEncrpytionExtension: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
233+
"The StorageAccountType property for a DataDisk will return Standard_LRS and Premium_LRS");
234+
232235
if (this.ShouldProcess(VMScaleSetName, Properties.Resources.EnableDiskEncryptionAction)
233236
&& (this.Force.IsPresent ||
234237
this.ShouldContinue(Properties.Resources.EnableAzureDiskEncryptionConfirmation, Properties.Resources.EnableAzureDiskEncryptionCaption))) // Change this.

src/ResourceManager/Compute/Commands.Compute/Generated/ComputeAutomationBaseCmdlet.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using System.Management.Automation;
3030
using System.Reflection;
3131
using System.Text;
32+
using System.Text.RegularExpressions;
3233

3334
namespace Microsoft.Azure.Commands.Compute.Automation
3435
{
@@ -290,6 +291,22 @@ private static Tuple<string, string, int> MakeTuple(string key, string value, in
290291
{
291292
return new Tuple<string, string, int>(key, value, depth);
292293
}
294+
295+
public static string GetResourceGroupName(string resourceId)
296+
{
297+
if (string.IsNullOrEmpty(resourceId)) { return null; }
298+
Regex r = new Regex(@"(.*?)/resourcegroups/(?<rgname>\S+)/providers/(.*?)", RegexOptions.IgnoreCase);
299+
Match m = r.Match(resourceId);
300+
return m.Success ? m.Groups["rgname"].Value : null;
301+
}
302+
303+
public static string GetResourceName(string resourceId, string resourceName)
304+
{
305+
if (string.IsNullOrEmpty(resourceId)) { return null; }
306+
Regex r = new Regex(@"(.*?)/" + resourceName + @"/(?<rgname>\S+)", RegexOptions.IgnoreCase);
307+
Match m = r.Match(resourceId);
308+
return m.Success ? m.Groups["rgname"].Value : null;
309+
}
293310
}
294311
public static class LocationStringExtensions
295312
{

src/ResourceManager/Compute/Commands.Compute/Generated/ContainerService/Config/AddAzureRmContainerServiceAgentPoolProfileCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ private void Run()
8282

8383
var vAgentPoolProfiles = new Microsoft.Azure.Management.Compute.Models.ContainerServiceAgentPoolProfile();
8484

85-
vAgentPoolProfiles.Name = this.Name;
85+
vAgentPoolProfiles.Name = this.MyInvocation.BoundParameters.ContainsKey("Name") ? this.Name : null;
8686
vAgentPoolProfiles.Count = this.Count;
87-
vAgentPoolProfiles.VmSize = this.VmSize;
88-
vAgentPoolProfiles.DnsPrefix = this.DnsPrefix;
87+
vAgentPoolProfiles.VmSize = this.MyInvocation.BoundParameters.ContainsKey("VmSize") ? this.VmSize : null;
88+
vAgentPoolProfiles.DnsPrefix = this.MyInvocation.BoundParameters.ContainsKey("DnsPrefix") ? this.DnsPrefix : null;
8989
this.ContainerService.AgentPoolProfiles.Add(vAgentPoolProfiles);
9090
WriteObject(this.ContainerService);
9191
}

0 commit comments

Comments
 (0)