Skip to content

Commit a29269d

Browse files
authored
Merge pull request #11393 from dingmeng-xue/fix-network
Replace Sql management client using generic rest client
2 parents 0f3ceed + 74f488f commit a29269d

32 files changed

+1784
-987
lines changed

src/Network/Network.Test/Network.Test.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<PackageReference Include="Microsoft.Azure.Management.Redis" Version="4.4.1" />
2222
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
2323
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.10.0-preview" />
24-
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.37.0-preview" />
2524
</ItemGroup>
2625

2726
<ItemGroup>

src/Network/Network.Test/ScenarioTests/NetworkTestRunner.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ protected NetworkTestRunner(ITestOutputHelper output)
2525
helper.GetRMModulePath("AzureRM.Network.psd1"),
2626
helper.GetRMModulePath("AzureRM.Compute.psd1"),
2727
helper.GetRMModulePath("AzureRM.Storage.psd1"),
28-
helper.GetRMModulePath("AzureRM.Sql.psd1"),
2928
helper.GetRMModulePath("AzureRM.ContainerInstance.psd1"),
3029
helper.GetRMModulePath("AzureRM.OperationalInsights.psd1"),
3130
helper.GetRMModulePath("AzureRM.ManagedServiceIdentity.psd1"),

src/Network/Network.Test/ScenarioTests/PrivateLinkServiceTests.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function Test-PrivateEndpointConnectionCRUD
127127
# Setup
128128
$rgname = Get-ResourceGroupName;
129129
$rname = Get-ResourceName;
130-
$location = Get-ProviderLocation "Microsoft.Network/privateLinkServices" "eastus2";
130+
$location = Get-ProviderLocation "Microsoft.Network/privateLinkServices" "eastus";
131131
# Dependency parameters
132132
$IpConfigurationName = "IpConfigurationName";
133133
$vnetName = Get-ResourceName;
@@ -186,12 +186,14 @@ function Test-PrivateEndpointConnectionCRUD
186186
Assert-NotNull $pecApprove;
187187
Assert-AreEqual "Approved" $pecApprove.PrivateLinkServiceConnectionState.Status
188188

189-
Start-TestSleep 30000
189+
Start-TestSleep 20000
190190

191191
# Remove Private Endpoint Connection
192192
$pecRemove = Remove-AzPrivateEndpointConnection -ResourceId $pecGet.Id -PassThru -Force
193193
Assert-AreEqual true $pecRemove
194194

195+
Start-TestSleep 15000
196+
195197
# Get Private Endpoint Connection again
196198
$pecGet2 = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $sqlResourceId
197199
Assert-Null($pecGet2)

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.PrivateLinkServiceTests/TestPrivateEndpointConnectionCRUD.json

Lines changed: 858 additions & 696 deletions
Large diffs are not rendered by default.

src/Network/Network.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagedServiceIdentity", ".
2222
EndProject
2323
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage", "..\Storage\Storage\Storage.csproj", "{A2591FA5-BF93-4358-9097-E6D58FE1DDC4}"
2424
EndProject
25-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sql", "..\Sql\Sql\Sql.csproj", "{F5235941-9E3A-4C98-8D69-FBBDD0E8C6F0}"
26-
EndProject
2725
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage.Management", "..\Storage\Storage.Management\Storage.Management.csproj", "{3D03EFA7-4C10-480E-89E3-C2FDF0580AB5}"
2826
EndProject
2927
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}"
@@ -76,10 +74,6 @@ Global
7674
{A2591FA5-BF93-4358-9097-E6D58FE1DDC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
7775
{A2591FA5-BF93-4358-9097-E6D58FE1DDC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
7876
{A2591FA5-BF93-4358-9097-E6D58FE1DDC4}.Release|Any CPU.Build.0 = Release|Any CPU
79-
{F5235941-9E3A-4C98-8D69-FBBDD0E8C6F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80-
{F5235941-9E3A-4C98-8D69-FBBDD0E8C6F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
81-
{F5235941-9E3A-4C98-8D69-FBBDD0E8C6F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
82-
{F5235941-9E3A-4C98-8D69-FBBDD0E8C6F0}.Release|Any CPU.Build.0 = Release|Any CPU
8377
{3D03EFA7-4C10-480E-89E3-C2FDF0580AB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8478
{3D03EFA7-4C10-480E-89E3-C2FDF0580AB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
8579
{3D03EFA7-4C10-480E-89E3-C2FDF0580AB5}.Release|Any CPU.ActiveCfg = Release|Any CPU

src/Network/Network/Az.Network.psd1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ DotNetFrameworkVersion = '4.7.2'
5656
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.7.3'; })
5757

5858
# Assemblies that must be loaded prior to importing this module
59-
RequiredAssemblies = 'AutoMapper.dll', 'Microsoft.Azure.Management.Network.dll',
60-
'Microsoft.Azure.Management.Sql.dll'
59+
RequiredAssemblies = 'AutoMapper.dll', 'Microsoft.Azure.Management.Network.dll'
6160

6261
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
6362
# ScriptsToProcess = @()

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Update-AzVirtualHubVnetConnection
2525
- New-AzVirtualHub
2626
- Update-AzVirtualHub
27+
* Removed Sql Management SDK dependency
2728

2829
## Version 2.3.2
2930
* Updated Sql Management SDK.

src/Network/Network/Common/NetworkClient.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
17-
using Microsoft.Azure.Commands.Common.Authentication.Models;
1817
using Microsoft.Azure.Management.Network;
1918
using Microsoft.Azure.Management.Network.Models;
20-
using Microsoft.Azure.Management.Sql;
2119
using Microsoft.Rest;
2220
using Microsoft.Rest.Azure;
2321
using Newtonsoft.Json;
@@ -37,23 +35,6 @@ public partial class NetworkClient
3735
{
3836
public INetworkManagementClient NetworkManagementClient { get; set; }
3937

40-
public ISqlManagementClient SqlManagementClient
41-
{
42-
get
43-
{
44-
if (sqlManagementClient == null)
45-
{
46-
sqlManagementClient = AzureSession.Instance.ClientFactory.CreateArmClient<SqlManagementClient>(azureContext, AzureEnvironment.Endpoint.ResourceManager);
47-
}
48-
return sqlManagementClient;
49-
}
50-
set
51-
{
52-
sqlManagementClient = value;
53-
}
54-
}
55-
private ISqlManagementClient sqlManagementClient = null;
56-
5738
private IAzureContext azureContext;
5839

5940
public Action<string> VerboseLogger { get; set; }

src/Network/Network/Network.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<ItemGroup>
1515
<PackageReference Include="AutoMapper" Version="6.2.2" />
1616
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.19.0-preview" />
17-
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.41.0-preview" />
1817
</ItemGroup>
1918

2019
<ItemGroup>

src/Network/Network/PrivateLinkService/GetAzurePrivateLinkServiceCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Management.Network.Models;
1516
using Microsoft.Azure.Commands.Network.Models;
1617
using Microsoft.Azure.Management.Network;
1718
using System.Collections.Generic;
1819
using System.Management.Automation;
19-
using Microsoft.Azure.Management.Network.Models;
2020
using Microsoft.Rest.Azure;
2121
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
22-
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
22+
using NM = Microsoft.Azure.Management.Network.Models;
2323

2424
namespace Microsoft.Azure.Commands.Network
2525
{
@@ -75,7 +75,7 @@ public override void Execute()
7575
}
7676
else
7777
{
78-
IPage<PrivateLinkService> plsPage;
78+
IPage<NM.PrivateLinkService> plsPage;
7979
if (ShouldListByResourceGroup(ResourceGroupName, Name))
8080
{
8181
plsPage = this.PrivateLinkServiceClient.List(this.ResourceGroupName);
@@ -86,7 +86,7 @@ public override void Execute()
8686
}
8787

8888

89-
var plsList = ListNextLink<PrivateLinkService>.GetAllResourcesByPollingNextLink(plsPage, this.PrivateLinkServiceClient.ListNext);
89+
var plsList = ListNextLink<NM.PrivateLinkService>.GetAllResourcesByPollingNextLink(plsPage, this.PrivateLinkServiceClient.ListNext);
9090
var psPLSs = new List<PSPrivateLinkService>();
9191
foreach (var pls in plsList)
9292
{
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.Rest.Azure;
16+
using Newtonsoft.Json;
17+
using System.Collections;
18+
using System.Collections.Generic;
19+
20+
namespace Microsoft.Azure.Commands.Network.PrivateLinkService.Models
21+
{
22+
/// <summary>
23+
/// Defines a page in Azure responses.
24+
/// </summary>
25+
/// <typeparam name="T">Type of the page content items</typeparam>
26+
[JsonObject]
27+
public class Page<T> : IPage<T>
28+
{
29+
/// <summary>
30+
/// Gets the link to the next page.
31+
/// </summary>
32+
[JsonProperty("nextLink")]
33+
public string NextPageLink { get; private set; }
34+
35+
[JsonProperty("value")]
36+
private List<T> Items { get; set; }
37+
38+
/// <summary>
39+
/// Returns an enumerator that iterates through the collection.
40+
/// </summary>
41+
/// <returns>A an enumerator that can be used to iterate through the collection.</returns>
42+
public IEnumerator<T> GetEnumerator()
43+
{
44+
return Items == null ? System.Linq.Enumerable.Empty<T>().GetEnumerator() : Items.GetEnumerator();
45+
}
46+
47+
/// <summary>
48+
/// Returns an enumerator that iterates through the collection.
49+
/// </summary>
50+
/// <returns>A an enumerator that can be used to iterate through the collection.</returns>
51+
IEnumerator IEnumerable.GetEnumerator()
52+
{
53+
return GetEnumerator();
54+
}
55+
}
56+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 Newtonsoft.Json;
16+
17+
namespace Microsoft.Azure.Commands.Network.PrivateLinkService.Models
18+
{
19+
/// <summary>
20+
/// A private endpoint connection
21+
/// </summary>
22+
[Rest.Serialization.JsonTransformation]
23+
public partial class PrivateEndpointConnection : ProxyResource
24+
{
25+
/// <summary>
26+
/// Initializes a new instance of the PrivateEndpointConnection class.
27+
/// </summary>
28+
public PrivateEndpointConnection()
29+
{
30+
CustomInit();
31+
}
32+
33+
/// <summary>
34+
/// Initializes a new instance of the PrivateEndpointConnection class.
35+
/// </summary>
36+
/// <param name="id">Resource ID.</param>
37+
/// <param name="name">Resource name.</param>
38+
/// <param name="type">Resource type.</param>
39+
/// <param name="privateEndpoint">Private endpoint which the connection
40+
/// belongs to.</param>
41+
/// <param name="privateLinkServiceConnectionState">Connection state of
42+
/// the private endpoint connection.</param>
43+
/// <param name="provisioningState">State of the private endpoint
44+
/// connection.</param>
45+
public PrivateEndpointConnection(string id = default(string), string name = default(string), string type = default(string), PrivateEndpointProperty privateEndpoint = default(PrivateEndpointProperty), PrivateLinkServiceConnectionStateProperty privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionStateProperty), string provisioningState = default(string))
46+
: base(id, name, type)
47+
{
48+
PrivateEndpoint = privateEndpoint;
49+
PrivateLinkServiceConnectionState = privateLinkServiceConnectionState;
50+
ProvisioningState = provisioningState;
51+
CustomInit();
52+
}
53+
54+
/// <summary>
55+
/// An initialization method that performs custom operations like setting defaults
56+
/// </summary>
57+
partial void CustomInit();
58+
59+
/// <summary>
60+
/// Gets or sets private endpoint which the connection belongs to.
61+
/// </summary>
62+
[JsonProperty(PropertyName = "properties.privateEndpoint")]
63+
public PrivateEndpointProperty PrivateEndpoint { get; set; }
64+
65+
/// <summary>
66+
/// Gets or sets connection state of the private endpoint connection.
67+
/// </summary>
68+
[JsonProperty(PropertyName = "properties.privateLinkServiceConnectionState")]
69+
public PrivateLinkServiceConnectionStateProperty PrivateLinkServiceConnectionState { get; set; }
70+
71+
/// <summary>
72+
/// Gets state of the private endpoint connection.
73+
/// </summary>
74+
[JsonProperty(PropertyName = "properties.provisioningState")]
75+
public string ProvisioningState { get; private set; }
76+
77+
/// <summary>
78+
/// Validate the object.
79+
/// </summary>
80+
/// <exception cref="ValidationException">
81+
/// Thrown if validation fails
82+
/// </exception>
83+
public virtual void Validate()
84+
{
85+
if (PrivateLinkServiceConnectionState != null)
86+
{
87+
PrivateLinkServiceConnectionState.Validate();
88+
}
89+
}
90+
}
91+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.Rest.Azure;
16+
using Newtonsoft.Json;
17+
18+
namespace Microsoft.Azure.Commands.Network.PrivateLinkService.Models
19+
{
20+
public partial class PrivateEndpointProperty : IResource
21+
{
22+
/// <summary>
23+
/// Initializes a new instance of the PrivateEndpointProperty class.
24+
/// </summary>
25+
public PrivateEndpointProperty()
26+
{
27+
CustomInit();
28+
}
29+
30+
/// <summary>
31+
/// Initializes a new instance of the PrivateEndpointProperty class.
32+
/// </summary>
33+
/// <param name="id">Resource id of the private endpoint.</param>
34+
public PrivateEndpointProperty(string id = default(string))
35+
{
36+
Id = id;
37+
CustomInit();
38+
}
39+
40+
/// <summary>
41+
/// An initialization method that performs custom operations like setting defaults
42+
/// </summary>
43+
partial void CustomInit();
44+
45+
/// <summary>
46+
/// Gets or sets resource id of the private endpoint.
47+
/// </summary>
48+
[JsonProperty(PropertyName = "id")]
49+
public string Id { get; set; }
50+
51+
}
52+
}

0 commit comments

Comments
 (0)