Skip to content

Commit d6d314d

Browse files
authored
Merge pull request #5701 from muwaqar/muwaqar/private-dns-public-preview
Adding support for Private DNS zones Public Preview
2 parents 26ce798 + 702754c commit d6d314d

File tree

73 files changed

+18706
-38490
lines changed

Some content is hidden

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

73 files changed

+18706
-38490
lines changed

TestMappings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@
113113
".\\src\\ResourceManager\\Network\\Commands.Network.Test\\bin\\Debug\\Microsoft.Azure.Commands.Network.Test.dll",
114114
".\\src\\ResourceManager\\RecoveryServices.Backup\\Commands.RecoveryServices.Backup.Test\\bin\\Debug\\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll",
115115
".\\src\\ResourceManager\\ServiceFabric\\Commands.ServiceFabric.Test\\bin\\Debug\\Microsoft.Azure.Commands.ServiceFabric.Test.dll",
116-
".\\src\\ResourceManager\\Sql\\Commands.Sql.Test\\bin\\Debug\\Microsoft.Azure.Commands.Sql.Test.dll"
116+
".\\src\\ResourceManager\\Sql\\Commands.Sql.Test\\bin\\Debug\\Microsoft.Azure.Commands.Sql.Test.dll",
117+
".\\src\\ResourceManager\\Dns\\Commands.Dns.Test\\bin\\Debug\\Microsoft.Azure.Commands.Dns.Test.dll"
117118
],
118119
"src/ResourceManager/NotificationHubs /": [
119120
".\\src\\ResourceManager\\NotificationHubs\\Commands.NotificationHubs.Test\\bin\\Debug\\Microsoft.Azure.Commands.NotificationHubs.Test.dll"

src/ResourceManager/Dns/AzureRM.Dns.psd1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ NestedModules = @('.\Microsoft.Azure.Commands.Dns.dll')
7272
FunctionsToExport = @()
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75-
CmdletsToExport = 'Get-AzureRmDnsRecordSet', 'New-AzureRmDnsRecordConfig',
76-
'Remove-AzureRmDnsRecordSet', 'Set-AzureRmDnsRecordSet',
77-
'Remove-AzureRmDnsRecordConfig', 'Add-AzureRmDnsRecordConfig',
78-
'New-AzureRmDnsRecordSet', 'Get-AzureRmDnsZone',
75+
CmdletsToExport = 'Get-AzureRmDnsRecordSet', 'New-AzureRmDnsRecordConfig',
76+
'Remove-AzureRmDnsRecordSet', 'Set-AzureRmDnsRecordSet',
77+
'Remove-AzureRmDnsRecordConfig', 'Add-AzureRmDnsRecordConfig',
78+
'New-AzureRmDnsRecordSet', 'Get-AzureRmDnsZone',
7979
'Remove-AzureRmDnsZone', 'Set-AzureRmDnsZone', 'New-AzureRmDnsZone'
8080

8181
# Variables to export from this module
@@ -123,7 +123,7 @@ PrivateData = @{
123123
# ExternalModuleDependencies = @()
124124

125125
} # End of PSData hashtable
126-
126+
127127
} # End of PrivateData hashtable
128128

129129
# HelpInfo URI of this module

src/ResourceManager/Dns/ChangeLog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Support for Private DNS Zones (Public Preview)
22+
- Adds ability to create DNS zones that are visible only to the associated virtual networks
2123

2224
## Version 4.0.1
2325
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
2426

2527
## Version 4.0.0
2628
* Support for CAA record types in Azure DNS
27-
- Supports all operations on CAA record type
29+
- Supports all operations on CAA record type
2830
* Add support for online help
2931
- Run Get-Help with the -Online parameter to open the online help in your default Internet browser
3032

src/ResourceManager/Dns/Commands.Dns.Test/Commands.Dns.Test.csproj

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.Management.Dns, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6565
<SpecificVersion>False</SpecificVersion>
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.2.0.0-preview\lib\net452\Microsoft.Azure.Management.Dns.dll</HintPath>
66+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.2.2.0-preview\lib\net452\Microsoft.Azure.Management.Dns.dll</HintPath>
67+
<Private>True</Private>
68+
</Reference>
69+
<Reference Include="Microsoft.Azure.Management.Network, Version=17.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70+
<SpecificVersion>False</SpecificVersion>
71+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.17.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
6772
<Private>True</Private>
6873
</Reference>
6974
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -191,6 +196,10 @@
191196
<Project>{d3804b64-c0d3-48f8-82ec-1f632f833c9e}</Project>
192197
<Name>Commands.Common.Authentication</Name>
193198
</ProjectReference>
199+
<ProjectReference Include="..\..\..\Common\Commands.Common.Network\Commands.Common.Network.csproj">
200+
<Project>{1338f7ae-7111-4ed3-8916-2d0fecc876f4}</Project>
201+
<Name>Commands.Common.Network</Name>
202+
</ProjectReference>
194203
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">
195204
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
196205
<Name>Commands.Common</Name>
@@ -331,6 +340,21 @@
331340
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetNewRecordNoName.json">
332341
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
333342
</None>
343+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestPrivateZoneCrud.json">
344+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
345+
</None>
346+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestPrivateZoneCrudByVirtualNetworkIds.json">
347+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
348+
</None>
349+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestPrivateZoneCrudByVirtualNetworkObjects.json">
350+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
351+
</None>
352+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestPrivateZoneCrudRegistrationVirtualNetwork.json">
353+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
354+
</None>
355+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestPrivateZoneCrudResolutionVirtualNetwork.json">
356+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
357+
</None>
334358
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrud.json">
335359
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
336360
</None>

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/Common.ps1

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ function Get-ResourceName
3030
return getAssetName
3131
}
3232

33+
<#
34+
.SYNOPSIS
35+
Gets valid virtual network name
36+
#>
37+
function Get-VirtualNetworkName
38+
{
39+
return getAssetName
40+
}
41+
3342
<#
3443
.SYNOPSIS
3544
Gets the default location for a provider
@@ -38,21 +47,21 @@ function Get-ProviderLocation($provider)
3847
{
3948
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
4049
{
41-
$namespace = $provider.Split("/")[0]
42-
if($provider.Contains("/"))
43-
{
44-
$type = $provider.Substring($namespace.Length + 1)
45-
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
46-
47-
if ($location -eq $null)
48-
{
49-
return "West US"
50-
} else
51-
{
52-
return $location.Locations[0]
53-
}
50+
$namespace = $provider.Split("/")[0]
51+
if($provider.Contains("/"))
52+
{
53+
$type = $provider.Substring($namespace.Length + 1)
54+
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
55+
56+
if ($location -eq $null)
57+
{
58+
return "West US"
59+
} else
60+
{
61+
return $location.Locations[0]
62+
}
5463
}
55-
64+
5665
return "West US"
5766
}
5867

@@ -71,6 +80,18 @@ function TestSetup-CreateResourceGroup
7180
return $resourceGroup
7281
}
7382

83+
<#
84+
.SYNOPSIS
85+
Creates a virtual network to use in tests
86+
#>
87+
function TestSetup-CreateVirtualNetwork($resourceGroup)
88+
{
89+
$virtualNetworkName = Get-VirtualNetworkName
90+
$location = Get-ProviderLocation "microsoft.network/virtualNetworks"
91+
$virtualNetwork = New-AzureRmVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroup.ResourceGroupName -Location $location -AddressPrefix "10.0.0.0/8"
92+
return $virtualNetwork
93+
}
94+
7495
function Get-RandomZoneName
7596
{
7697
$prefix = getAssetName;

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/DnsTestsBase.cs

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

15+
using System;
1516
using System.Collections.Generic;
17+
using System.IO;
18+
using System.Linq;
1619
using Microsoft.Azure.Commands.Common.Authentication;
20+
using Microsoft.Azure.Gallery;
21+
using Microsoft.Azure.Management.Authorization;
22+
using Microsoft.Azure.Management.Dns;
23+
using Microsoft.Azure.Management.Network;
24+
using Microsoft.Azure.Management.Resources;
25+
using Microsoft.Azure.Subscriptions;
1726
using Microsoft.Azure.Test.HttpRecorder;
18-
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
27+
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
28+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
29+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
30+
using LegacyTest = Microsoft.Azure.Test;
31+
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
32+
using TestUtilities = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities;
1933

2034
namespace Microsoft.Azure.Commands.ScenarioTest.DnsTests
2135
{
22-
using Microsoft.Azure.Gallery;
23-
using Microsoft.Azure.Management.Authorization;
24-
using Microsoft.Azure.Management.Dns;
25-
using Microsoft.Azure.Management.Resources;
26-
using Microsoft.Azure.Subscriptions;
27-
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
28-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
29-
using System;
30-
using System.IO;
31-
using System.Linq;
32-
using WindowsAzure.Commands.Test.Utilities.Common;
33-
using LegacyTest = Microsoft.Azure.Test;
34-
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
35-
using TestUtilities = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities;
36-
3736
public class DnsTestsBase : RMTestBase
3837
{
3938
private LegacyTest.CSMTestEnvironmentFactory csmTestFactory;
4039

41-
4240
private readonly EnvironmentSetupHelper helper;
4341

44-
4542
public ResourceManagementClient ResourceManagementClient { get; private set; }
4643

4744
public SubscriptionClient SubscriptionClient { get; private set; }
4845

49-
5046
public GalleryClient GalleryClient { get; private set; }
5147

52-
5348
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
5449

55-
5650
public DnsManagementClient DnsClient { get; private set; }
5751

52+
public NetworkManagementClient NetworkManagementClient { get; private set; }
5853

5954
public static DnsTestsBase NewInstance
6055
{
@@ -71,21 +66,22 @@ protected DnsTestsBase()
7166
}
7267

7368

74-
protected void SetupManagementClients(MockContext context)
69+
protected void SetupManagementClients(MockContext context)
7570
{
7671
this.ResourceManagementClient = this.GetResourceManagementClient();
7772
this.SubscriptionClient = this.GetSubscriptionClient();
7873
this.GalleryClient = this.GetGalleryClient();
7974
this.AuthorizationManagementClient = this.GetAuthorizationManagementClient();
80-
this.DnsClient = this.GetFeatureClient(context);
81-
75+
this.DnsClient = this.GetFeatureClient(context);
76+
this.NetworkManagementClient = this.GetNetworkManagementClient(context);
8277

8378
this.helper.SetupManagementClients(
8479
this.ResourceManagementClient,
8580
this.SubscriptionClient,
8681
this.GalleryClient,
8782
this.AuthorizationManagementClient,
88-
this.DnsClient);
83+
this.DnsClient,
84+
this.NetworkManagementClient);
8985
}
9086

9187

@@ -97,9 +93,9 @@ public void RunPowerShellTest(params string[] scripts)
9793

9894
this.RunPsTestWorkflow(
9995
() => scripts,
100-
// no custom initializer
96+
// no custom initializer
10197
null,
102-
// no custom cleanup
98+
// no custom cleanup
10399
null,
104100
callingClassType,
105101
mockName);
@@ -133,7 +129,7 @@ public void RunPsTestWorkflow(
133129
}
134130

135131

136-
this.SetupManagementClients(context);
132+
this.SetupManagementClients(context);
137133

138134

139135
this.helper.SetupEnvironment(AzureModule.AzureResourceManager);
@@ -148,6 +144,7 @@ public void RunPsTestWorkflow(
148144
helper.RMProfileModule,
149145
helper.RMResourceModule,
150146
helper.GetRMModulePath("AzureRM.Dns.psd1"),
147+
helper.GetRMModulePath("AzureRM.Network.psd1"),
151148
"AzureRM.Resources.ps1");
152149

153150
try
@@ -178,6 +175,11 @@ protected ResourceManagementClient GetResourceManagementClient()
178175
return LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
179176
}
180177

178+
protected NetworkManagementClient GetNetworkManagementClient(MockContext context)
179+
{
180+
return context.GetServiceClient<NetworkManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
181+
}
182+
181183
private AuthorizationManagementClient GetAuthorizationManagementClient()
182184
{
183185
return LegacyTest.TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
@@ -193,9 +195,9 @@ private GalleryClient GetGalleryClient()
193195
return LegacyTest.TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
194196
}
195197

196-
private DnsManagementClient GetFeatureClient(MockContext context)
198+
private DnsManagementClient GetFeatureClient(MockContext context)
197199
{
198-
return context.GetServiceClient<DnsManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
200+
return context.GetServiceClient<DnsManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
199201
}
200202
}
201203
}

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/ZoneTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@ public void TestZoneCrud()
3131
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrud");
3232
}
3333

34+
[Fact]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
36+
public void TestPrivateZoneCrud()
37+
{
38+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-PrivateZoneCrud");
39+
}
40+
41+
[Fact]
42+
[Trait(Category.AcceptanceType, Category.CheckIn)]
43+
public void TestPrivateZoneCrudRegistrationVirtualNetwork()
44+
{
45+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-PrivateZoneCrudRegistrationVnet");
46+
}
47+
48+
[Fact]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void TestPrivateZoneCrudResolutionVirtualNetwork()
51+
{
52+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-PrivateZoneCrudResolutionVnet");
53+
}
54+
55+
[Fact]
56+
[Trait(Category.AcceptanceType, Category.CheckIn)]
57+
public void TestPrivateZoneCrudByVirtualNetworkIds()
58+
{
59+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-PrivateZoneCrudByVirtualNetworkIds");
60+
}
61+
62+
[Fact]
63+
[Trait(Category.AcceptanceType, Category.CheckIn)]
64+
public void TestPrivateZoneCrudByVirtualNetworkObjects()
65+
{
66+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-PrivateZoneCrudByVirtualNetworkObjects");
67+
}
68+
3469
[Fact]
3570
[Trait(Category.AcceptanceType, Category.CheckIn)]
3671
public void TestZoneCrudTrimsDot()

0 commit comments

Comments
 (0)