Skip to content

Commit 4786d8f

Browse files
authored
Merge pull request #1 from Azure/preview
Merging from preview pr branch
2 parents fd7ac47 + 0a0dd87 commit 4786d8f

File tree

139 files changed

+114152
-4496
lines changed

Some content is hidden

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

139 files changed

+114152
-4496
lines changed

src/Common/Commands.Common.Network/Models/EffectiveNetworkSecurityGroup.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ public EffectiveNetworkSecurityGroup()
3636
/// that is applied.</param>
3737
/// <param name="effectiveSecurityRules">A collection of effective
3838
/// security rules.</param>
39-
public EffectiveNetworkSecurityGroup(SubResource networkSecurityGroup = default(SubResource), EffectiveNetworkSecurityGroupAssociation association = default(EffectiveNetworkSecurityGroupAssociation), IList<EffectiveNetworkSecurityRule> effectiveSecurityRules = default(IList<EffectiveNetworkSecurityRule>))
39+
/// <param name="tagMap">Tag map.</param>
40+
public EffectiveNetworkSecurityGroup(SubResource networkSecurityGroup = default(SubResource), EffectiveNetworkSecurityGroupAssociation association = default(EffectiveNetworkSecurityGroupAssociation), IList<EffectiveNetworkSecurityRule> effectiveSecurityRules = default(IList<EffectiveNetworkSecurityRule>), IDictionary<string, List<string>> tagMap = default(IDictionary<string, List<string>>))
4041
{
4142
NetworkSecurityGroup = networkSecurityGroup;
4243
Association = association;
4344
EffectiveSecurityRules = effectiveSecurityRules;
45+
TagMap = tagMap;
4446
CustomInit();
4547
}
4648

@@ -66,5 +68,10 @@ public EffectiveNetworkSecurityGroup()
6668
[JsonProperty(PropertyName = "effectiveSecurityRules")]
6769
public IList<EffectiveNetworkSecurityRule> EffectiveSecurityRules { get; set; }
6870

71+
/// <summary>
72+
/// Gets or sets the tag map.
73+
/// </summary>
74+
[JsonProperty(PropertyName = "tagMap")]
75+
public IDictionary<string, List<string>> TagMap { get; set; }
6976
}
7077
}

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ protected void LogQosEvent()
522522

523523
try
524524
{
525+
_metricHelper.SetPSHost(this.Host);
525526
_metricHelper.LogQoSEvent(_qosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
526527
_metricHelper.FlushMetric();
527528
WriteDebug("Finish sending metric.");

src/Common/Commands.Common/MetricHelper.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System;
2323
using System.Collections.Generic;
2424
using System.Diagnostics;
25+
using System.Management.Automation.Host;
2526
using System.Security.Cryptography;
2627
using System.Text;
2728

@@ -31,6 +32,8 @@ public class MetricHelper
3132
{
3233
protected INetworkHelper _networkHelper;
3334
private const int FlushTimeoutInMilli = 5000;
35+
private const string DefaultPSVersion = "3.0.0.0";
36+
private const string EventName = "cmdletInvocation";
3437

3538
/// <summary>
3639
/// The collection of telemetry clients.
@@ -58,6 +61,26 @@ public class MetricHelper
5861

5962
private AzurePSDataCollectionProfile _profile;
6063

64+
private static PSHost _host;
65+
66+
private static string _psVersion;
67+
68+
protected string PSVersion
69+
{
70+
get
71+
{
72+
if (_host != null)
73+
{
74+
_psVersion = _host.Version.ToString();
75+
}
76+
else
77+
{
78+
_psVersion = DefaultPSVersion;
79+
}
80+
return _psVersion;
81+
}
82+
}
83+
6184
public string HashMacAddress
6285
{
6386
get
@@ -171,7 +194,7 @@ private void LogUsageEvent(AzurePSQoSEvent qos)
171194
{
172195
var pageViewTelemetry = new PageViewTelemetry
173196
{
174-
Name = qos.CommandName ?? "empty",
197+
Name = EventName,
175198
Duration = qos.Duration,
176199
Timestamp = qos.StartTime
177200
};
@@ -217,13 +240,19 @@ private void LoadTelemetryClientContext(AzurePSQoSEvent qos, TelemetryContext cl
217240
}
218241
}
219242

243+
public void SetPSHost(PSHost host)
244+
{
245+
_host = host;
246+
}
247+
220248
private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string, string> eventProperties)
221249
{
222250
if (qos == null)
223251
{
224252
return;
225253
}
226254

255+
eventProperties.Add("Command", qos.CommandName);
227256
eventProperties.Add("IsSuccess", qos.IsSuccess.ToString());
228257
eventProperties.Add("ModuleName", qos.ModuleName);
229258
eventProperties.Add("ModuleVersion", qos.ModuleVersion);
@@ -234,6 +263,8 @@ private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string,
234263
eventProperties.Add("x-ms-client-request-id", qos.ClientRequestId);
235264
eventProperties.Add("UserAgent", AzurePowerShell.UserAgentValue.ToString());
236265
eventProperties.Add("HashMacAddress", HashMacAddress);
266+
eventProperties.Add("PowerShellVersion", PSVersion);
267+
eventProperties.Add("Version", AzurePowerShell.AssemblyVersion);
237268
if (qos.InputFromPipeline != null)
238269
{
239270
eventProperties.Add("InputFromPipeline", qos.InputFromPipeline.Value.ToString());

src/Common/Commands.Common/Utilities/GeneralUtilities.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,28 @@ public static void EnsureDefaultProfileDirectoryExists()
430430
}
431431
}
432432

433+
/// <summary>
434+
/// Checks if collection has more than one element
435+
/// </summary>
436+
/// <typeparam name="T">Type of the collection.</typeparam>
437+
/// <param name="collection">Collection.</param>
438+
/// <returns></returns>
439+
public static bool HasMoreThanOneElement<T>(ICollection<T> collection)
440+
{
441+
return collection != null && collection.Count > 1;
442+
}
443+
444+
/// <summary>
445+
/// Checks if collection has only one element
446+
/// </summary>
447+
/// <typeparam name="T">Type of the collection.</typeparam>
448+
/// <param name="collection">Collection.</param>
449+
/// <returns></returns>
450+
public static bool HasSingleElement<T>(ICollection<T> collection)
451+
{
452+
return collection != null && collection.Count == 1;
453+
}
454+
433455
/// <summary>
434456
/// Clear the current storage account from the context - guarantees that only one storage account will be active
435457
/// at a time.

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public EnvironmentSetupHelper()
6565
TestExecutionHelpers.SetUpSessionAndProfile();
6666
var datastore = new MemoryDataStore();
6767
AzureSession.Instance.DataStore = datastore;
68-
var rmprofile = new AzureRmProfile(Path.Combine(AzureSession.Instance.ARMProfileDirectory, AzureSession.Instance.ARMProfileFile));
68+
var rmprofile = new AzureRmProfile(Path.Combine(AzureSession.Instance.ProfileDirectory, AzureSession.Instance.ProfileFile));
6969
rmprofile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()));
7070
rmprofile.DefaultContext = new AzureContext(new AzureSubscription(), new AzureAccount(), rmprofile.EnvironmentTable["foo"], new AzureTenant());
7171
rmprofile.DefaultContext.Subscription.SetEnvironment("foo");
@@ -135,6 +135,15 @@ public string RMStorageDataPlaneModule
135135
}
136136
}
137137

138+
public string RMNetworkModule
139+
{
140+
get
141+
{
142+
return Path.Combine(this.PackageDirectory,
143+
@"ResourceManager\AzureResourceManager\AzureRM.Network\AzureRM.Network.psd1");
144+
}
145+
}
146+
138147
public string GetRMModulePath(string psd1FileName)
139148
{
140149
string basename = Path.GetFileNameWithoutExtension(psd1FileName);
@@ -256,12 +265,12 @@ private void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode)
256265
private void SetAuthenticationFactory(AzureModule mode, TestEnvironment environment)
257266
{
258267
#if !NETSTANDARD
259-
if(environment.AuthorizationContext.Certificate != null)
268+
if (environment.AuthorizationContext.Certificate != null)
260269
{
261270
AzureSession.Instance.AuthenticationFactory = new MockCertificateAuthenticationFactory(environment.UserName,
262271
environment.AuthorizationContext.Certificate);
263272
}
264-
else if(environment.AuthorizationContext.TokenCredentials.ContainsKey(TokenAudience.Management))
273+
else if (environment.AuthorizationContext.TokenCredentials.ContainsKey(TokenAudience.Management))
265274
{
266275
var httpMessage = new HttpRequestMessage();
267276
environment.AuthorizationContext.TokenCredentials[TokenAudience.Management]
@@ -430,4 +439,4 @@ private void SetupPowerShellModules(System.Management.Automation.PowerShell powe
430439
}
431440

432441
}
433-
}
442+
}

src/ResourceManager/Dns/ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21-
21+
* Support for Private DNS Zones (Public Preview feature)
22+
- Adds ability to create DNS Zones that are visible only within associated virtual networks
2223
## Version 3.3.1
2324

2425
## Version 3.3.0

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.Management.Dns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6565
<SpecificVersion>False</SpecificVersion>
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.7.2-preview\lib\net45\Microsoft.Azure.Management.Dns.dll</HintPath>
66+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.11.0-preview\lib\net452\Microsoft.Azure.Management.Dns.dll</HintPath>
67+
<Private>True</Private>
68+
</Reference>
69+
<Reference Include="Microsoft.Azure.Management.Network, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.14.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
6771
<Private>True</Private>
6872
</Reference>
6973
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -104,7 +108,7 @@
104108
<Private>True</Private>
105109
</Reference>
106110
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
107-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
111+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
108112
<Private>True</Private>
109113
</Reference>
110114
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -328,6 +332,12 @@
328332
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrud.json">
329333
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
330334
</None>
335+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudPrivateRegistrationVnet.json">
336+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
337+
</None>
338+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudPrivateResolutionVnet.json">
339+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
340+
</None>
331341
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudTrimsDot.json">
332342
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
333343
</None>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ function Get-ResourceGroupName
2121
return getAssetName
2222
}
2323

24+
<#
25+
.SYNOPSIS
26+
Gets valid resource group name
27+
#>
28+
function Get-VirtualNetworkName
29+
{
30+
return getAssetName
31+
}
32+
2433
<#
2534
.SYNOPSIS
2635
Gets valid resource name
@@ -71,6 +80,18 @@ function TestSetup-CreateResourceGroup
7180
return $resourceGroup
7281
}
7382

83+
<#
84+
.SYNOPSIS
85+
Creates a resource group to use in tests
86+
#>
87+
function TestSetup-CreateVirtualNetwork ($resourceGroup)
88+
{
89+
$virtualNetworkName = Get-VirtualNetworkName
90+
$virtualNetwork = New-AzureRmVirtualNetwork -Name $virtualNetworkName -resourceGroupName $resourceGroup.ResourceGroupName -location "WestUS" -AddressPrefix "192.168.1.0/24"
91+
return $virtualNetwork
92+
}
93+
94+
7495
function Get-RandomZoneName
7596
{
7697
$prefix = getAssetName;

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using System.Collections.Generic;
1616
using Microsoft.Azure.Commands.Common.Authentication;
17+
using Microsoft.Azure.Management.Network;
1718
using Microsoft.Azure.Test.HttpRecorder;
1819
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
1920

@@ -38,23 +39,19 @@ public class DnsTestsBase : RMTestBase
3839
{
3940
private LegacyTest.CSMTestEnvironmentFactory csmTestFactory;
4041

41-
4242
private readonly EnvironmentSetupHelper helper;
43-
44-
43+
4544
public ResourceManagementClient ResourceManagementClient { get; private set; }
4645

4746
public SubscriptionClient SubscriptionClient { get; private set; }
4847

49-
5048
public GalleryClient GalleryClient { get; private set; }
5149

52-
5350
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
5451

55-
5652
public DnsManagementClient DnsClient { get; private set; }
5753

54+
public NetworkManagementClient NetworkManagementClient { get; private set; }
5855

5956
public static DnsTestsBase NewInstance
6057
{
@@ -64,28 +61,28 @@ public static DnsTestsBase NewInstance
6461
}
6562
}
6663

67-
6864
protected DnsTestsBase()
6965
{
7066
this.helper = new EnvironmentSetupHelper();
7167
}
7268

73-
7469
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);
75+
this.DnsClient = this.GetFeatureClient(context);
76+
this.NetworkManagementClient = this.GetNetworkManagementClient(context);
8177

8278

8379
this.helper.SetupManagementClients(
8480
this.ResourceManagementClient,
8581
this.SubscriptionClient,
8682
this.GalleryClient,
8783
this.AuthorizationManagementClient,
88-
this.DnsClient);
84+
this.DnsClient,
85+
this.NetworkManagementClient);
8986
}
9087

9188

@@ -133,12 +130,15 @@ public void RunPsTestWorkflow(
133130
}
134131

135132

136-
this.SetupManagementClients(context);
137-
133+
this.SetupManagementClients(context);
138134

139135
this.helper.SetupEnvironment(AzureModule.AzureResourceManager);
140136

141137

138+
139+
140+
141+
142142
string callingClassName = callingClassType
143143
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
144144
.Last();
@@ -148,6 +148,7 @@ public void RunPsTestWorkflow(
148148
helper.RMProfileModule,
149149
helper.RMResourceModule,
150150
helper.GetRMModulePath("AzureRM.Dns.psd1"),
151+
helper.GetRMModulePath("AzureRM.Network.psd1"),
151152
"AzureRM.Resources.ps1");
152153

153154
try
@@ -178,6 +179,12 @@ protected ResourceManagementClient GetResourceManagementClient()
178179
return LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
179180
}
180181

182+
protected NetworkManagementClient GetNetworkManagementClient(MockContext context)
183+
{
184+
return context.GetServiceClient<NetworkManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
185+
}
186+
187+
181188
private AuthorizationManagementClient GetAuthorizationManagementClient()
182189
{
183190
return LegacyTest.TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);

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

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

34+
[Fact]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
36+
public void TestZoneCrudPrivateResolutionVnet()
37+
{
38+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrudPrivateResolutionVnet");
39+
}
40+
41+
[Fact]
42+
[Trait(Category.AcceptanceType, Category.CheckIn)]
43+
public void TestZoneCrudPrivateRegistrationVnet()
44+
{
45+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrudPrivateRegistrationVnet");
46+
}
47+
3448
[Fact]
3549
[Trait(Category.AcceptanceType, Category.CheckIn)]
3650
public void TestZoneCrudTrimsDot()

0 commit comments

Comments
 (0)