diff --git a/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.csproj b/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.csproj
index f244d19f8d81..caa40859af4d 100644
--- a/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.csproj
+++ b/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.csproj
@@ -34,8 +34,6 @@
-
-
diff --git a/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.psd1 b/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.psd1
index b5688055982d..869d3c9af620 100644
--- a/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.psd1
+++ b/tools/Az.Tools.Predictor/Az.Tools.Predictor/Az.Tools.Predictor.psd1
@@ -35,7 +35,7 @@ Description = 'Microsoft Azure PowerShell Predictor: Provide prediction while us
PowerShellVersion = '7.1'
# Modules that must be imported into the global environment prior to importing this module
-RequiredModules = @(@{ModuleName = 'Az'; ModuleVersion = '3.0.0'; })
+# RequiredModules = @()
NestedModules = @("Microsoft.Azure.PowerShell.Tools.AzPredictor.dll")
diff --git a/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorConstants.cs b/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorConstants.cs
index 2dd3051c2c78..98582e59a5b4 100644
--- a/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorConstants.cs
+++ b/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorConstants.cs
@@ -67,6 +67,7 @@ internal static class AzPredictorConstants
///
/// The azure profile directory name.
///
+ // See AzureDirectoryName in https://github.com/Azure/azure-powershell/blob/master/src/Accounts/Authentication/Properties/Resources.resx
public const string AzureProfileDirectoryName = ".Azure";
}
}
diff --git a/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorTelemetryClient.cs b/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorTelemetryClient.cs
index 8ed0dd868bba..1ddc854f888d 100644
--- a/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorTelemetryClient.cs
+++ b/tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorTelemetryClient.cs
@@ -14,8 +14,7 @@
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
-using Microsoft.Azure.Commands.Common.Authentication;
-using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
+using Microsoft.Azure.PowerShell.Tools.AzPredictor.Profile;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -30,40 +29,6 @@ namespace Microsoft.Azure.PowerShell.Tools.AzPredictor
///
sealed class AzPredictorTelemetryClient : ITelemetryClient
{
- ///
- /// A simple session class that provides neccessary information to get the profile.
- ///
- private sealed class TelemetrySession : AzureSession
- {
- ///
- /// Constructs a new instance of
- ///
- public TelemetrySession()
- {
- DataStore = new DiskDataStore();
- ProfileDirectory = Path.Combine(
- Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- AzPredictorConstants.AzureProfileDirectoryName);
- }
-
- ///
- public override TraceLevel AuthenticationLegacyTraceLevel
- {
- get => TraceLevel.Off;
- set { }
- }
-
- ///
- public override TraceListenerCollection AuthenticationTraceListeners => Trace.Listeners;
-
- ///
- public override SourceLevels AuthenticationTraceSourceLevel
- {
- get => SourceLevels.Off;
- set { }
- }
- }
-
private const string TelemetryEventPrefix = "Az.Tools.Predictor";
///
@@ -74,31 +39,6 @@ public override SourceLevels AuthenticationTraceSourceLevel
private readonly TelemetryClient _telemetryClient;
- private object lockObject = new object();
- private AzurePSDataCollectionProfile _cachedProfile;
-
- private AzurePSDataCollectionProfile DataCollectionProfile
- {
- get
- {
- if (_cachedProfile != null)
- {
- return _cachedProfile;
- }
-
- lock (lockObject)
- {
- if (_cachedProfile == null)
- {
- var controller = DataCollectionController.Create(new TelemetrySession());
- _cachedProfile = controller.GetProfile(() => { });
- }
-
- return _cachedProfile;
- }
- }
- }
-
///
/// Constructs a new instance of
///
@@ -255,9 +195,7 @@ public void OnGetSuggestionError(Exception e)
/// true if allowed
private bool IsDataCollectionAllowed()
{
- if (DataCollectionProfile != null &&
- DataCollectionProfile.EnableAzureDataCollection.HasValue &&
- DataCollectionProfile.EnableAzureDataCollection.Value)
+ if (AzurePSDataCollectionProfile.Instance.EnableAzureDataCollection == true)
{
return true;
}
diff --git a/tools/Az.Tools.Predictor/Az.Tools.Predictor/Predictor.cs b/tools/Az.Tools.Predictor/Az.Tools.Predictor/Predictor.cs
index 0c6e16464740..8075c4818c4a 100644
--- a/tools/Az.Tools.Predictor/Az.Tools.Predictor/Predictor.cs
+++ b/tools/Az.Tools.Predictor/Az.Tools.Predictor/Predictor.cs
@@ -40,7 +40,7 @@ public Predictor(IList modelPredictions, ParameterValuePredictor paramet
this._parameterValuePredictor = parameterValuePredictor;
this._predictions = new List();
- foreach (var predictionTextRaw in modelPredictions)
+ foreach (var predictionTextRaw in modelPredictions ?? Enumerable.Empty())
{
var predictionText = EscapePredictionText(predictionTextRaw);
Ast ast = Parser.ParseInput(predictionText, out Token[] tokens, out _);
diff --git a/tools/Az.Tools.Predictor/build.proj b/tools/Az.Tools.Predictor/build.proj
index 23ba552c0883..11a3ab126a6b 100644
--- a/tools/Az.Tools.Predictor/build.proj
+++ b/tools/Az.Tools.Predictor/build.proj
@@ -22,21 +22,13 @@
- build
- publish
+ build
-
-
-
-
-
-
-