Skip to content

Commit 0bfed89

Browse files
committed
Merge pull request #536 from DeepakRajendranMsft/IdnsOnNic
add IDns to New-Nic
2 parents 07ebfcf + 451a969 commit 0bfed89

File tree

15 files changed

+1557
-24
lines changed

15 files changed

+1557
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.3-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
75-
<Private>True</Private>
74+
<SpecificVersion>False</SpecificVersion>
75+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.7-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
7676
</Reference>
7777
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7878
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.Authorization" version="0.19.2-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Compute" version="7.0.0-preview" targetFramework="net45" />
11-
<package id="Microsoft.Azure.Management.Network" version="2.0.3-preview" targetFramework="net45" />
11+
<package id="Microsoft.Azure.Management.Network" version="2.0.7-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.18.1-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@
8181
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.7.0.0-preview\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
8282
<Private>True</Private>
8383
</Reference>
84-
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
85-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.3-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
86-
<Private>True</Private>
84+
<Reference Include="Microsoft.Azure.Management.Network">
85+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.7-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
8786
</Reference>
8887
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8988
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Authorization" version="0.19.2-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Compute" version="7.0.0-preview" targetFramework="net45" />
12-
<package id="Microsoft.Azure.Management.Network" version="2.0.3-preview" targetFramework="net45" />
12+
<package id="Microsoft.Azure.Management.Network" version="2.0.7-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Management.Resources" version="2.18.1-preview" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
1515
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@
6666
<SpecificVersion>False</SpecificVersion>
6767
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.19.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6868
</Reference>
69-
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70-
<SpecificVersion>False</SpecificVersion>
71-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.4-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
69+
<Reference Include="Microsoft.Azure.Management.Network">
70+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.7-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
7271
</Reference>
7372
<Reference Include="Microsoft.Azure.ResourceManager">
7473
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.1-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -222,6 +221,9 @@
222221
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceCRUDUsingId.json">
223222
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
224223
</None>
224+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceIDns.json">
225+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
226+
</None>
225227
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceSet.json">
226228
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
227229
</None>

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkInterfaceTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,12 @@ public void TestNetworkInterfaceSet()
5353
{
5454
NetworkResourcesController.NewInstance.RunPsTest("Test-NetworkInterfaceSet");
5555
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void TestNetworkInterfaceIDns()
60+
{
61+
NetworkResourcesController.NewInstance.RunPsTest("Test-NetworkInterfaceIDns");
62+
}
5663
}
5764
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkInterfaceTests.ps1

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,64 @@ function Test-NetworkInterfaceSet
375375
# Cleanup
376376
Clean-ResourceGroup $rgname
377377
}
378+
}
379+
380+
<#
381+
.SYNOPSIS
382+
Tests creating new simple public networkinterface with Idns.
383+
#>
384+
function Test-NetworkInterfaceIDns
385+
{
386+
# Setup
387+
$rgname = Get-ResourceGroupName
388+
$vnetName = Get-ResourceName
389+
$subnetName = Get-ResourceName
390+
$publicIpName = Get-ResourceName
391+
$nicName = Get-ResourceName
392+
$domainNameLabel = Get-ResourceName
393+
$rglocation = Get-ProviderLocation ResourceManagement
394+
$resourceTypeParent = "Microsoft.Network/networkInterfaces"
395+
<#
396+
uncomment after IDNS is enabled in all locations
397+
$location = Get-ProviderLocation $resourceTypeParent
398+
#>
399+
$location = "centralus"
400+
401+
try
402+
{
403+
# Create the resource group
404+
$resourceGroup = New-AzureResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}
405+
406+
# Create the Virtual Network
407+
$subnet = New-AzureVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
408+
$vnet = New-AzurevirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
409+
410+
# Create NetworkInterface
411+
$actualNic = New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgname -Location $location -Subnet $vnet.Subnets[0] -InternalDnsNameLabel "idnstest"
412+
$expectedNic = Get-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgname
413+
414+
Assert-AreEqual $expectedNic.ResourceGroupName $actualNic.ResourceGroupName
415+
Assert-AreEqual $expectedNic.Name $actualNic.Name
416+
Assert-AreEqual $expectedNic.Location $actualNic.Location
417+
Assert-AreEqual "Succeeded" $expectedNic.ProvisioningState
418+
Assert-AreEqual $expectedNic.IpConfigurations[0].Name $actualNic.IpConfigurations[0].Name
419+
Assert-AreEqual $expectedNic.IpConfigurations[0].PublicIpAddress.Id $actualNic.IpConfigurations[0].PublicIpAddress.Id
420+
Assert-AreEqual $expectedNic.IpConfigurations[0].Subnet.Id $actualNic.IpConfigurations[0].Subnet.Id
421+
Assert-NotNull $expectedNic.IpConfigurations[0].PrivateIpAddress
422+
Assert-AreEqual "Dynamic" $expectedNic.IpConfigurations[0].PrivateIpAllocationMethod
423+
Assert-AreEqual "idnstest" $expectedNic.DnsSettings.InternalDnsNameLabel
424+
Assert-Null $expectedNic.DnsSettings.InternalFqdn
425+
426+
# Delete NetworkInterface
427+
$delete = Remove-AzureNetworkInterface -ResourceGroupName $rgname -name $nicName -PassThru -Force
428+
Assert-AreEqual true $delete
429+
430+
$list = Get-AzureNetworkInterface -ResourceGroupName $rgname
431+
Assert-AreEqual 0 @($list).Count
432+
}
433+
finally
434+
{
435+
# Cleanup
436+
Clean-ResourceGroup $rgname
437+
}
378438
}

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkInterfaceTests/TestNetworkInterfaceIDns.json

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.Authorization" version="0.19.2-preview" targetFramework="net45" />
10-
<package id="Microsoft.Azure.Management.Network" version="2.0.4-preview" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.Network" version="2.0.7-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.18.1-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.19.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7474
</Reference>
7575
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
76-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.4-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
77-
<Private>True</Private>
76+
<SpecificVersion>False</SpecificVersion>
77+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.7-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
7878
</Reference>
7979
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8080
<SpecificVersion>False</SpecificVersion>
@@ -207,7 +207,7 @@
207207
<Compile Include="Models\PSProbeProtocol.cs" />
208208
<Compile Include="Models\PSAddressSpace.cs" />
209209
<Compile Include="Models\PSDhcpOptions.cs" />
210-
<Compile Include="Models\PSDnsSettings.cs" />
210+
<Compile Include="Models\PSNetworkInterfaceDnsSettings.cs" />
211211
<Compile Include="Models\PSNetworkInterface.cs" />
212212
<Compile Include="Models\PSNetworkInterfaceIpConfiguration.cs" />
213213
<Compile Include="Models\PSProvisioningState.cs" />

src/ResourceManager/Network/Commands.Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ protected override void Configure()
101101
// NetworkInterface
102102
// CNM to MNM
103103
Mapper.CreateMap<CNM.PSNetworkInterface, MNM.NetworkInterface>();
104-
Mapper.CreateMap<CNM.PSDnsSettings, MNM.DnsSettings>();
104+
Mapper.CreateMap<CNM.PSNetworkInterfaceDnsSettings, MNM.NetworkInterfaceDnsSettings>();
105105
Mapper.CreateMap<CNM.PSNetworkInterfaceIpConfiguration, MNM.NetworkInterfaceIpConfiguration>();
106106

107107
// MNM to CNM
108108
Mapper.CreateMap<MNM.NetworkInterface, CNM.PSNetworkInterface>();
109-
Mapper.CreateMap<MNM.DnsSettings, CNM.PSDnsSettings>();
109+
Mapper.CreateMap<MNM.NetworkInterfaceDnsSettings, CNM.PSNetworkInterfaceDnsSettings>();
110110
Mapper.CreateMap<MNM.NetworkInterfaceIpConfiguration, CNM.PSNetworkInterfaceIpConfiguration>();
111111

112112
// LoadBalancer

src/ResourceManager/Network/Commands.Network/Models/PSNetworkInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class PSNetworkInterface : PSTopLevelResource
2424

2525
public List<PSNetworkInterfaceIpConfiguration> IpConfigurations { get; set; }
2626

27-
public PSDnsSettings DnsSettings { get; set; }
27+
public PSNetworkInterfaceDnsSettings DnsSettings { get; set; }
2828

2929
public string MacAddress { get; set; }
3030

@@ -49,7 +49,7 @@ public string IpConfigurationsText
4949
[JsonIgnore]
5050
public string DnsSettingsText
5151
{
52-
get { return JsonConvert.SerializeObject(DnsSettings, Formatting.Indented); }
52+
get { return JsonConvert.SerializeObject(this.DnsSettings, Formatting.Indented); }
5353
}
5454

5555
[JsonIgnore]

src/ResourceManager/Network/Commands.Network/Models/PSDnsSettings.cs renamed to src/ResourceManager/Network/Commands.Network/Models/PSNetworkInterfaceDnsSettings.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
namespace Microsoft.Azure.Commands.Network.Models
1818
{
19-
public class PSDnsSettings
19+
public class PSNetworkInterfaceDnsSettings
2020
{
2121
public List<string> DnsServers { get; set; }
2222

2323
public List<string> AppliedDnsServers { get; set; }
24+
25+
public string InternalDnsNameLabel { get; set; }
26+
27+
public string InternalFqdn { get; set; }
2428
}
2529
}

src/ResourceManager/Network/Commands.Network/NetworkInterface/NewAzureNetworkInterfaceCommand.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ public class NewAzureNetworkInterfaceCommand : NetworkInterfaceBaseCmdlet
143143
HelpMessage = "The list of Dns Servers")]
144144
public List<string> DnsServer { get; set; }
145145

146+
[Parameter(
147+
Mandatory = false,
148+
ValueFromPipelineByPropertyName = true,
149+
HelpMessage = "The Internal Dns name")]
150+
public string InternalDnsNameLabel { get; set; }
151+
146152
[Parameter(
147153
Mandatory = false,
148154
ValueFromPipelineByPropertyName = true,
@@ -261,10 +267,18 @@ private PSNetworkInterface CreateNetworkInterface()
261267
}
262268
}
263269

264-
if (this.DnsServer != null)
270+
if (this.DnsServer != null || this.InternalDnsNameLabel != null)
265271
{
266-
networkInterface.DnsSettings = new PSDnsSettings();
267-
networkInterface.DnsSettings.DnsServers = this.DnsServer;
272+
networkInterface.DnsSettings = new PSNetworkInterfaceDnsSettings();
273+
if (this.DnsServer != null)
274+
{
275+
networkInterface.DnsSettings.DnsServers = this.DnsServer;
276+
}
277+
if (this.InternalDnsNameLabel != null)
278+
{
279+
networkInterface.DnsSettings.InternalDnsNameLabel = this.InternalDnsNameLabel;
280+
}
281+
268282
}
269283

270284
networkInterface.IpConfigurations.Add(nicIpConfiguration);

src/ResourceManager/Network/Commands.Network/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Authorization" version="0.19.2-preview" targetFramework="net45" />
11-
<package id="Microsoft.Azure.Management.Network" version="2.0.4-preview" targetFramework="net45" />
11+
<package id="Microsoft.Azure.Management.Network" version="2.0.7-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.18.1-preview" targetFramework="net45" />
13-
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
1413
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1514
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1615
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />

0 commit comments

Comments
 (0)