Skip to content

Commit 12e061c

Browse files
authored
PrivateDNS: generate package-2018-09 (Azure#913)
* PrivateDNS: generate package-2018-09 * PrivateDNS: add in solutions * PrivateDNS: add interfaces of private zone * PrivateDNS: add interfaces of private dns record set * PrivateDNS: add interfaces of records * PrivateDNS: add implementations of records * PrivateDNS: add implementations of private zone * PrivateDNS: add implementations of private dns record set * PrivateDNS: add private dns manager * PrivateDNS: add interfaces and implementations for virtual network link * PrivateDNS: add tests and sample with record sessions * PrivateDNS: update in test script * PrivateDNS: fix alignment * PrivateDNS: update by review comments * PrivateDNS: update by review comments * PrivateDNS: fix typo in Azure.cs
1 parent b7c00c1 commit 12e061c

File tree

110 files changed

+45783
-33
lines changed

Some content is hidden

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

110 files changed

+45783
-33
lines changed

Fluent.SDK.sln

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.
2121
EndProject
2222
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.KeyVault.Fluent", "src\ResourceManagement\KeyVault\Microsoft.Azure.Management.KeyVault.Fluent.csproj", "{1911A39E-FA13-48F6-A7DD-98B0A7EE973B}"
2323
EndProject
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.PrivateDns.Fluent", "src\ResourceManagement\PrivateDns\Microsoft.Azure.Management.PrivateDns.Fluent.csproj", "{CEC27EF8-F20B-421D-A429-0EC438E57630}"
25+
EndProject
2426
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Redis.Fluent", "src\ResourceManagement\RedisCache\Microsoft.Azure.Management.Redis.Fluent.csproj", "{399E50C9-629E-4FD3-9F19-B7DFA64C9E40}"
2527
EndProject
2628
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.ResourceManager.Fluent", "src\ResourceManagement\ResourceManager\Microsoft.Azure.Management.ResourceManager.Fluent.csproj", "{E5C3B599-F17E-4BE2-9E67-97246EB14162}"
@@ -81,6 +83,10 @@ Global
8183
{48CCF7A7-1F38-4681-9311-E8FCB1A0EB18}.Debug|Any CPU.Build.0 = Debug|Any CPU
8284
{48CCF7A7-1F38-4681-9311-E8FCB1A0EB18}.Release|Any CPU.ActiveCfg = Release|Any CPU
8385
{48CCF7A7-1F38-4681-9311-E8FCB1A0EB18}.Release|Any CPU.Build.0 = Release|Any CPU
86+
{CEC27EF8-F20B-421D-A429-0EC438E57630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87+
{CEC27EF8-F20B-421D-A429-0EC438E57630}.Debug|Any CPU.Build.0 = Debug|Any CPU
88+
{CEC27EF8-F20B-421D-A429-0EC438E57630}.Release|Any CPU.ActiveCfg = Release|Any CPU
89+
{CEC27EF8-F20B-421D-A429-0EC438E57630}.Release|Any CPU.Build.0 = Release|Any CPU
8490
{1D87885A-C7DB-4DB8-8572-F0DFC53318AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8591
{1D87885A-C7DB-4DB8-8572-F0DFC53318AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
8692
{1D87885A-C7DB-4DB8-8572-F0DFC53318AE}.Release|Any CPU.ActiveCfg = Release|Any CPU

Fluent.Samples.sln

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.
2727
EndProject
2828
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Network.Fluent", "src\ResourceManagement\Network\Microsoft.Azure.Management.Network.Fluent.csproj", "{83752382-9E71-45FA-813A-15B5F8A6FCB0}"
2929
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.PrivateDns.Fluent", "src\ResourceManagement\PrivateDns\Microsoft.Azure.Management.PrivateDns.Fluent.csproj", "{7ACB3B27-BA2C-4BE9-8D8E-E3C7B265060E}"
31+
EndProject
3032
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Redis.Fluent", "src\ResourceManagement\RedisCache\Microsoft.Azure.Management.Redis.Fluent.csproj", "{15B618D3-6FC3-4ECA-A4F8-57F51F3C137D}"
3133
EndProject
3234
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.ResourceManager.Fluent", "src\ResourceManagement\ResourceManager\Microsoft.Azure.Management.ResourceManager.Fluent.csproj", "{F6070835-D98E-4750-B747-BEBC7D470E8A}"
@@ -105,6 +107,10 @@ Global
105107
{83752382-9E71-45FA-813A-15B5F8A6FCB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
106108
{83752382-9E71-45FA-813A-15B5F8A6FCB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
107109
{83752382-9E71-45FA-813A-15B5F8A6FCB0}.Release|Any CPU.Build.0 = Release|Any CPU
110+
{7ACB3B27-BA2C-4BE9-8D8E-E3C7B265060E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
111+
{7ACB3B27-BA2C-4BE9-8D8E-E3C7B265060E}.Debug|Any CPU.Build.0 = Debug|Any CPU
112+
{7ACB3B27-BA2C-4BE9-8D8E-E3C7B265060E}.Release|Any CPU.ActiveCfg = Release|Any CPU
113+
{7ACB3B27-BA2C-4BE9-8D8E-E3C7B265060E}.Release|Any CPU.Build.0 = Release|Any CPU
108114
{15B618D3-6FC3-4ECA-A4F8-57F51F3C137D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109115
{15B618D3-6FC3-4ECA-A4F8-57F51F3C137D}.Debug|Any CPU.Build.0 = Debug|Any CPU
110116
{15B618D3-6FC3-4ECA-A4F8-57F51F3C137D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -176,6 +182,7 @@ Global
176182
{173AD141-C258-4EE6-B85E-90C87DE6A171} = {6FB01238-DA67-4BC0-98B7-01F07947419F}
177183
{4479E694-BCAD-4CD4-9B73-3F1C4629DE5A} = {6FB01238-DA67-4BC0-98B7-01F07947419F}
178184
{83752382-9E71-45FA-813A-15B5F8A6FCB0} = {6FB01238-DA67-4BC0-98B7-01F07947419F}
185+
{7ACB3B27-BA2C-4BE9-8D8E-E3C7B265060E} = {6FB01238-DA67-4BC0-98B7-01F07947419F}
179186
{15B618D3-6FC3-4ECA-A4F8-57F51F3C137D} = {6FB01238-DA67-4BC0-98B7-01F07947419F}
180187
{F6070835-D98E-4750-B747-BEBC7D470E8A} = {6FB01238-DA67-4BC0-98B7-01F07947419F}
181188
{BBBCE191-2051-4610-A3D2-8418646854F1} = {6FB01238-DA67-4BC0-98B7-01F07947419F}

Fluent.Tests.sln

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.
3838
EndProject
3939
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Network.Fluent", "src\ResourceManagement\Network\Microsoft.Azure.Management.Network.Fluent.csproj", "{9CAE8EAC-324D-4498-942E-4F8AFA9A4FE0}"
4040
EndProject
41+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.PrivateDns.Fluent", "src\ResourceManagement\PrivateDns\Microsoft.Azure.Management.PrivateDns.Fluent.csproj", "{502FAC64-38A0-4035-B512-309E12AB82C8}"
42+
EndProject
4143
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Redis.Fluent", "src\ResourceManagement\RedisCache\Microsoft.Azure.Management.Redis.Fluent.csproj", "{D1CF9FCF-097B-4CB5-A1BD-A3432E036DC7}"
4244
EndProject
4345
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.ResourceManager.Fluent", "src\ResourceManagement\ResourceManager\Microsoft.Azure.Management.ResourceManager.Fluent.csproj", "{07F97082-7478-42B2-9F8C-3D2D167D5A0B}"
@@ -124,6 +126,10 @@ Global
124126
{9CAE8EAC-324D-4498-942E-4F8AFA9A4FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
125127
{9CAE8EAC-324D-4498-942E-4F8AFA9A4FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
126128
{9CAE8EAC-324D-4498-942E-4F8AFA9A4FE0}.Release|Any CPU.Build.0 = Release|Any CPU
129+
{502FAC64-38A0-4035-B512-309E12AB82C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
130+
{502FAC64-38A0-4035-B512-309E12AB82C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
131+
{502FAC64-38A0-4035-B512-309E12AB82C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
132+
{502FAC64-38A0-4035-B512-309E12AB82C8}.Release|Any CPU.Build.0 = Release|Any CPU
127133
{D1CF9FCF-097B-4CB5-A1BD-A3432E036DC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
128134
{D1CF9FCF-097B-4CB5-A1BD-A3432E036DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
129135
{D1CF9FCF-097B-4CB5-A1BD-A3432E036DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -196,6 +202,7 @@ Global
196202
{05790214-3D01-449E-BFBB-C7F280C53022} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
197203
{B747657A-4CFE-4B3C-A387-B21FAD5AF4C2} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
198204
{9CAE8EAC-324D-4498-942E-4F8AFA9A4FE0} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
205+
{502FAC64-38A0-4035-B512-309E12AB82C8} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
199206
{D1CF9FCF-097B-4CB5-A1BD-A3432E036DC7} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
200207
{07F97082-7478-42B2-9F8C-3D2D167D5A0B} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
201208
{16775A2E-CE93-4A6B-B6C0-EF7AF23238BC} = {6861600A-FFF3-49C3-8A91-7174F754EAED}
+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using Microsoft.Azure.Management.Compute.Fluent;
5+
using Microsoft.Azure.Management.Compute.Fluent.Models;
6+
using Microsoft.Azure.Management.Fluent;
7+
using Microsoft.Azure.Management.Network.Fluent;
8+
using Microsoft.Azure.Management.ResourceManager.Fluent;
9+
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
10+
using Microsoft.Azure.Management.Samples.Common;
11+
using System;
12+
using System.Collections.Generic;
13+
14+
namespace ManagePrivateDns
15+
{
16+
public class Program
17+
{
18+
private const string CustomDomainName = "private.contoso.com";
19+
20+
/**
21+
* Azure private DNS sample for managing DNS zones.
22+
* - Creates a private DNS zone (private.contoso.com)
23+
* - Creates a virtual network
24+
* - Link a virtual network
25+
* - Creates test virtual machines
26+
* - Creates an additional DNS record
27+
* - Test the private DNS zone
28+
*/
29+
public static void RunSample(IAzure azure)
30+
{
31+
string rgName = SdkContext.RandomResourceName("rgNEMV_", 24);
32+
string vnName = SdkContext.RandomResourceName("vnetwork1-", 24);
33+
string subnetName = SdkContext.RandomResourceName("subnet1-", 24);
34+
string linkName = SdkContext.RandomResourceName("vnlink1-", 24);
35+
string vm1Name = SdkContext.RandomResourceName("vm1-", 24);
36+
string vm2Name = SdkContext.RandomResourceName("vm2-", 24);
37+
string rsName = SdkContext.RandomResourceName("recordset1-", 24);
38+
39+
try
40+
{
41+
var resourceGroup = azure.ResourceGroups.Define(rgName)
42+
.WithRegion(Region.AsiaSouthEast)
43+
.Create();
44+
45+
//============================================================
46+
// Creates a private DNS zone
47+
48+
Utilities.Log("Creating private DNS zone " + CustomDomainName + "...");
49+
var privateDnsZone = azure.PrivateDnsZones.Define(CustomDomainName)
50+
.WithExistingResourceGroup(resourceGroup)
51+
.Create();
52+
53+
Utilities.Log("Created private DNS zone " + privateDnsZone.Name);
54+
Utilities.Print(privateDnsZone);
55+
56+
//============================================================
57+
// Creates a virtual network
58+
59+
Utilities.Log("Creating virtual network " + vnName + "...");
60+
INetwork virtualNetwork = azure.Networks.Define(vnName)
61+
.WithRegion(Region.AsiaSouthEast)
62+
.WithExistingResourceGroup(resourceGroup)
63+
.WithAddressSpace("10.2.0.0/16")
64+
.WithSubnet(subnetName, "10.2.0.0/24")
65+
.Create();
66+
Utilities.Log("Created virtual network " + virtualNetwork.Name);
67+
68+
//============================================================
69+
// Link a virtual network
70+
71+
Utilities.Log("Creating virtual network link " + linkName + " within private zone " + privateDnsZone.Name + " ...");
72+
privateDnsZone.Update()
73+
.DefineVirtualNetworkLink(linkName)
74+
.EnableAutoRegistration()
75+
.WithReferencedVirtualNetworkId(virtualNetwork.Id)
76+
.WithETagCheck()
77+
.Attach()
78+
.Apply();
79+
Utilities.Log("Linked a virtual network " + virtualNetwork.Id);
80+
Utilities.Print(privateDnsZone);
81+
82+
//============================================================
83+
// Creates test virtual machines
84+
85+
Utilities.Log("Creating first virtual machine " + vm1Name + "...");
86+
var virtualMachine1 = azure.VirtualMachines.Define(vm1Name)
87+
.WithRegion(Region.AsiaSouthEast)
88+
.WithExistingResourceGroup(resourceGroup)
89+
.WithExistingPrimaryNetwork(virtualNetwork)
90+
.WithSubnet(subnetName)
91+
.WithPrimaryPrivateIPAddressDynamic()
92+
.WithoutPrimaryPublicIPAddress()
93+
.WithPopularWindowsImage(KnownWindowsVirtualMachineImage.WindowsServer2012Datacenter)
94+
.WithAdminUsername("azureadmin")
95+
.WithAdminPassword("Azure12345678")
96+
.Create();
97+
Utilities.Log("Created first virtual machine " + virtualMachine1.Name);
98+
Utilities.Log("Starting first virtual machine " + virtualMachine1.Name + "...");
99+
virtualMachine1.Start();
100+
Utilities.Log("Started first virtual machine " + virtualMachine1.Name);
101+
102+
Utilities.Log("Creating second virtual machine " + vm2Name + "...");
103+
var virtualMachine2 = azure.VirtualMachines.Define(vm2Name)
104+
.WithRegion(Region.AsiaSouthEast)
105+
.WithExistingResourceGroup(resourceGroup)
106+
.WithExistingPrimaryNetwork(virtualNetwork)
107+
.WithSubnet(subnetName)
108+
.WithPrimaryPrivateIPAddressDynamic()
109+
.WithoutPrimaryPublicIPAddress()
110+
.WithPopularWindowsImage(KnownWindowsVirtualMachineImage.WindowsServer2012Datacenter)
111+
.WithAdminUsername("Foo12")
112+
.WithAdminPassword("BaR@12!Foo")
113+
.Create();
114+
Utilities.Log("Created second virtual machine " + virtualMachine2.Name);
115+
Utilities.Log("Starting second virtual machine " + virtualMachine2.Name + "...");
116+
virtualMachine2.Start();
117+
Utilities.Log("Started second virtual machine " + virtualMachine2.Name);
118+
119+
//============================================================
120+
// Creates an additional DNS record
121+
Utilities.Log("Creating additional record set " + rsName + "...");
122+
privateDnsZone.Update()
123+
.DefineARecordSet(rsName)
124+
.WithIPv4Address(virtualMachine1.GetPrimaryNetworkInterface().PrimaryPrivateIP)
125+
.Attach()
126+
.Apply();
127+
Utilities.Log("Created additional record set " + rsName);
128+
Utilities.Print(privateDnsZone);
129+
130+
//============================================================
131+
// Test the private DNS zone
132+
133+
string script1 = "New-NetFirewallRule -DisplayName \"Allow ICMPv4-In\" -Protocol ICMPv4";
134+
Utilities.Log("Preparing first command: " + script1);
135+
string script2 = "ping " + virtualMachine1.ComputerName + "." + CustomDomainName;
136+
Utilities.Log("Preparing second command: " + script2);
137+
string script3 = "ping " + rsName + "." + CustomDomainName;
138+
Utilities.Log("Preparing third command: " + script1);
139+
140+
Utilities.Log("Starting to run command...");
141+
var result = virtualMachine2.RunPowerShellScript(new List<string> { script1, script2, script3 }, new List<RunCommandInputParameter>());
142+
foreach (var info in result.Value)
143+
{
144+
Utilities.Log(info.Message);
145+
}
146+
}
147+
finally
148+
{
149+
try
150+
{
151+
Utilities.Log("Deleting Resource Group: " + rgName);
152+
azure.ResourceGroups.DeleteByName(rgName);
153+
Utilities.Log("Deleted Resource Group: " + rgName);
154+
}
155+
catch (Exception)
156+
{
157+
Utilities.Log("Did not create any resources in Azure. No clean up is necessary");
158+
}
159+
}
160+
}
161+
162+
public static void Main(string[] args)
163+
{
164+
try
165+
{
166+
//=================================================================
167+
// Authenticate
168+
var credentials = SdkContext.AzureCredentialsFactory.FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION"));
169+
170+
var azure = Azure
171+
.Configure()
172+
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
173+
.Authenticate(credentials)
174+
.WithDefaultSubscription();
175+
176+
// Print selected subscription
177+
Utilities.Log("Selected subscription: " + azure.SubscriptionId);
178+
179+
RunSample(azure);
180+
}
181+
catch (Exception e)
182+
{
183+
Utilities.Log(e);
184+
}
185+
}
186+
}
187+
}

Samples/Samples.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<ProjectReference Include="..\src\ResourceManagement\Monitor\Microsoft.Azure.Management.Monitor.Fluent.csproj" />
119119
<ProjectReference Include="..\src\ResourceManagement\Msi\Microsoft.Azure.Management.Msi.Fluent.csproj" />
120120
<ProjectReference Include="..\src\ResourceManagement\Network\Microsoft.Azure.Management.Network.Fluent.csproj" />
121+
<ProjectReference Include="..\src\ResourceManagement\PrivateDns\Microsoft.Azure.Management.PrivateDns.Fluent.csproj" />
121122
<ProjectReference Include="..\src\ResourceManagement\RedisCache\Microsoft.Azure.Management.Redis.Fluent.csproj" />
122123
<ProjectReference Include="..\src\ResourceManagement\ResourceManager\Microsoft.Azure.Management.ResourceManager.Fluent.csproj" />
123124
<ProjectReference Include="..\src\ResourceManagement\Search\Microsoft.Azure.Management.Search.Fluent.csproj" />

0 commit comments

Comments
 (0)