Skip to content

Commit c4b56b4

Browse files
committed
Merge branch 'preview' of https://github.com/Azure/azure-powershell-pr into applicationSecurityGroupsPr
2 parents 0bdec50 + 2db74e2 commit c4b56b4

File tree

259 files changed

+166909
-103495
lines changed

Some content is hidden

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

259 files changed

+166909
-103495
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/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.16.2.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
6868
</Reference>
6969
<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>
70+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.14.2.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
7171
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.Management.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -93,11 +93,11 @@
9393
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
9494
</Reference>
9595
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
96-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.9\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
96+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
9797
<Private>True</Private>
9898
</Reference>
9999
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
100-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.9\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
100+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
101101
<Private>True</Private>
102102
</Reference>
103103
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">

0 commit comments

Comments
 (0)