Skip to content

Commit 5d1ec50

Browse files
authored
Merge branch 'master' into patch-6
2 parents 58e45f9 + 7ee8c23 commit 5d1ec50

File tree

61 files changed

+10243
-2456
lines changed

Some content is hidden

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

61 files changed

+10243
-2456
lines changed

src/AlertsManagement/AlertsManagement/ActionRuleCommands/SetAzureActionRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private string DetermineScopeType(string value)
561561
}
562562
else if (tokens.Length >= 9)
563563
{
564-
return ScopeType.ResourceGroup;
564+
return ScopeType.Resource;
565565
}
566566
else
567567
{

src/Compute/Compute.Test/Compute.Test.csproj

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

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
15-
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.3.0" />
15+
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="29.0.0" />
1616
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.2" />
1717
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.14.0-preview" />
1818
</ItemGroup>

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/Compute.csproj

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

1414
<ItemGroup>
1515
<PackageReference Include="AutoMapper" Version="6.2.2" />
16-
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.3.0" />
16+
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="29.0.0" />
1717
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
1818
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.1" />
1919
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />

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))

src/HealthcareApis/HealthcareApis/ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@
1919
-->
2020
## Upcoming Release
2121

22+
* Added Error Handling in all cmdlets
23+
* Fixed few typos
24+
* Enable Set-AzHealthcareApisService to allow updating tags.
25+
26+
## Version 0.1.0
27+
2228
* Added following CRUD operation cmdlets to HealthcareApis service.
2329
* New-AzHealthcareApisService, Set-AzHealthcareApisService, Get-AzHealthcareApisService, Remove-AzHealthcareApisService
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.Commands.HealthcareApis.Properties;
16+
using System;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.PowerShell.Cmdlets.HealthcareApis.Common
20+
{
21+
public static class HealthcareApisArgumentValidator
22+
{
23+
public static bool ValidateObjectId(string accessPolicyObjectId)
24+
{
25+
if (!Guid.TryParse(accessPolicyObjectId, out _))
26+
{
27+
throw new PSArgumentException(Resources.invalidAccessPolicyObjectIdMessage);
28+
}
29+
30+
return true;
31+
}
32+
}
33+
}

src/HealthcareApis/HealthcareApis/Common/HealthcareApisBaseCmdlet.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Azure.PowerShell.Cmdlets.HealthcareApis.Common;
2222
using Microsoft.Rest.Azure;
2323
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Newtonsoft.Json;
2425
using System;
2526
using System.Collections.Generic;
2627
using System.Management.Automation;
@@ -160,14 +161,36 @@ public static List<PSHealthcareApisService> ToPSFhirServices(IPage<ServicesDescr
160161
{
161162
using (IEnumerator<ServicesDescription> sdenumerator = fhirServiceApps.GetEnumerator())
162163
{
163-
var newpne = new List<PSHealthcareApisService>();
164+
var fhirServiceList = new List<PSHealthcareApisService>();
164165
while (sdenumerator.MoveNext())
165166
{
166167
PSHealthcareApisService psHealthCareFhirService = ToPSFhirService(sdenumerator.Current);
167-
newpne.Add(psHealthCareFhirService);
168+
fhirServiceList.Add(psHealthCareFhirService);
168169
}
169170

170-
return newpne;
171+
return fhirServiceList;
172+
}
173+
}
174+
175+
public static ErrorRecord WriteErrorforBadrequest(ErrorDetailsException ex)
176+
{
177+
if (ex != null && !string.IsNullOrEmpty(ex.Response.Content))
178+
{
179+
ErrorDetailsInternal errorExtract = new ErrorDetailsInternal();
180+
errorExtract = JsonConvert.DeserializeObject<ErrorDetailsInternal>(ex.Response.Content);
181+
if (!string.IsNullOrEmpty(errorExtract.Message))
182+
{
183+
return new ErrorRecord(ex, errorExtract.Message, ErrorCategory.OpenError, ex);
184+
}
185+
else
186+
{
187+
return new ErrorRecord(ex, ex.Response.Content, ErrorCategory.OpenError, ex);
188+
}
189+
}
190+
else
191+
{
192+
Exception emptyEx = new Exception("Response object empty");
193+
return new ErrorRecord(emptyEx, "Response object was empty", ErrorCategory.OpenError, emptyEx);
171194
}
172195
}
173196
}

src/HealthcareApis/HealthcareApis/HealthcareApis/GetAzureRmHealthcareApisService.cs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,16 @@ public override void ExecuteCmdlet()
7272
{
7373
case ServiceNameParameterSet:
7474
{
75-
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);
76-
WriteHealthcareApisAccount(healthcareApisAccount);
75+
try
76+
{
77+
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);
78+
WriteHealthcareApisAccount(healthcareApisAccount);
79+
}
80+
catch (ErrorDetailsException wex)
81+
{
82+
WriteError(WriteErrorforBadrequest(wex));
83+
}
84+
7785
break;
7886
}
7987
case ResourceIdParameterSet:
@@ -83,23 +91,44 @@ public override void ExecuteCmdlet()
8391

8492
if (ValidateAndExtractName(this.ResourceId, out resourceGroupName, out resourceName))
8593
{
86-
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(resourceGroupName, resourceName);
87-
WriteHealthcareApisAccount(healthcareApisAccount);
94+
try
95+
{
96+
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(resourceGroupName, resourceName);
97+
WriteHealthcareApisAccount(healthcareApisAccount);
98+
}
99+
catch (ErrorDetailsException wex)
100+
{
101+
WriteError(WriteErrorforBadrequest(wex));
102+
}
88103
}
89104
break;
90105
}
91106
case ListParameterSet:
92107
{
93108
if (string.IsNullOrEmpty(this.ResourceGroupName))
94109
{
95-
IPage<ServicesDescription> healthcareApisServicesBySubscription = this.HealthcareApisClient.Services.List();
96-
this.WriteObject(ToPSFhirServices(healthcareApisServicesBySubscription), enumerateCollection: true);
110+
try
111+
{
112+
IPage<ServicesDescription> healthcareApisServicesBySubscription = this.HealthcareApisClient.Services.List();
113+
this.WriteObject(ToPSFhirServices(healthcareApisServicesBySubscription), enumerateCollection: true);
114+
}
115+
catch (ErrorDetailsException wex)
116+
{
117+
WriteError(WriteErrorforBadrequest(wex));
118+
}
97119
break;
98120
}
99121
else
100122
{
101-
IPage<ServicesDescription> healthcareApisServicesResourceGroup = this.HealthcareApisClient.Services.ListByResourceGroup(this.ResourceGroupName);
102-
this.WriteObject(ToPSFhirServices(healthcareApisServicesResourceGroup), enumerateCollection: true);
123+
try
124+
{
125+
IPage<ServicesDescription> healthcareApisServicesResourceGroup = this.HealthcareApisClient.Services.ListByResourceGroup(this.ResourceGroupName);
126+
this.WriteObject(ToPSFhirServices(healthcareApisServicesResourceGroup), enumerateCollection: true);
127+
}
128+
catch (ErrorDetailsException wex)
129+
{
130+
WriteError(WriteErrorforBadrequest(wex));
131+
}
103132
break;
104133
}
105134
}

0 commit comments

Comments
 (0)