Skip to content

Commit f1d931b

Browse files
committed
Updating infrastructure to avoid breakign changes
1 parent 489af88 commit f1d931b

File tree

8 files changed

+172
-161
lines changed

8 files changed

+172
-161
lines changed

src/Common/Commands.Common.Authentication.Abstractions/AzureEnvironment.cs

Lines changed: 129 additions & 114 deletions
Large diffs are not rendered by default.

src/Common/Commands.Common.Authentication.Abstractions/AzureEnvironmentConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ public static class AzureEnvironmentConstants
118118
/// <summary>
119119
/// The token audience for Log Analytics Queries
120120
/// </summary>
121-
public const string AzureOperationalInsightsServiceEndpointResourceId = "https://api.loganalytics.io";
121+
public const string AzureOperationalInsightsEndpointResourceId = "https://api.loganalytics.io";
122122

123123
/// <summary>
124124
/// The endpoint URI for Log Analytics Queries
125125
/// </summary>
126-
public const string AzureOperationalInsightsServiceEndpoint = "https://api.loganalytics.io/v1";
126+
public const string AzureOperationalInsightsEndpoint = "https://api.loganalytics.io/v1";
127127

128128
/// <summary>
129129
/// The domain name suffix for Azure DataLake services

src/Common/Commands.Common.Authentication.Abstractions/Extensions/AzureEnvironmentExtensions.cs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ public static bool TryGetEndpointUrl(this IAzureEnvironment environment, string
6868
case AzureEnvironment.Endpoint.BatchEndpointResourceId:
6969
endpoint = new Uri(environment.BatchEndpointResourceId);
7070
break;
71-
case AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId:
72-
endpoint = new Uri(environment.AzureOperationalInsightsEndpointResourceId);
73-
break;
74-
case AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint:
75-
endpoint = new Uri(environment.AzureOperationalInsightsEndpoint);
76-
break;
7771
default:
78-
result = false;
72+
result = environment.IsPropertySet(endpointName);
73+
if (result)
74+
{
75+
endpoint = new Uri(environment.GetProperty(endpointName));
76+
}
7977
break;
8078
}
8179

@@ -153,13 +151,9 @@ public static bool TryGetEndpointString(this IAzureEnvironment environment, stri
153151
case AzureEnvironment.Endpoint.BatchEndpointResourceId:
154152
propertyValue = environment.BatchEndpointResourceId;
155153
break;
156-
case AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId:
157-
propertyValue = environment.AzureOperationalInsightsEndpointResourceId;
158-
break;
159-
case AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint:
160-
propertyValue = environment.AzureOperationalInsightsEndpoint;
161-
break;
162154
default:
155+
// get property from the extended properties of the environment
156+
propertyValue = environment.GetProperty(endpointName);
163157
break;
164158
}
165159
}
@@ -271,11 +265,11 @@ public static void SetEndpoint(this IAzureEnvironment environment, string endpoi
271265
case AzureEnvironment.Endpoint.ServiceManagement:
272266
environment.ServiceManagementUrl = propertyValue;
273267
break;
274-
case AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId:
275-
environment.AzureOperationalInsightsEndpointResourceId = propertyValue;
268+
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId:
269+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, propertyValue);
276270
break;
277-
case AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint:
278-
environment.AzureOperationalInsightsEndpoint= propertyValue;
271+
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint:
272+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, propertyValue);
279273
break;
280274
}
281275
}
@@ -300,9 +294,9 @@ public static string GetTokenAudience(this IAzureEnvironment environment, string
300294
{
301295
resource = AzureEnvironment.Endpoint.DataLakeEndpointResourceId;
302296
}
303-
else if (targetEndpoint == AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId)
297+
else if (targetEndpoint == AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId)
304298
{
305-
resource = AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId;
299+
resource = AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId;
306300
}
307301

308302
return resource;
@@ -482,14 +476,6 @@ public static void CopyFrom(this IAzureEnvironment environment, IAzureEnvironmen
482476
{
483477
environment.BatchEndpointResourceId = other.BatchEndpointResourceId;
484478
}
485-
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId))
486-
{
487-
environment.AzureOperationalInsightsEndpointResourceId = other.AzureOperationalInsightsEndpointResourceId;
488-
}
489-
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint))
490-
{
491-
environment.AzureOperationalInsightsEndpoint= other.AzureOperationalInsightsEndpoint;
492-
}
493479

494480
environment.VersionProfiles.Clear();
495481
foreach (var profile in other.VersionProfiles)

src/Common/Commands.Common.Authentication.Abstractions/Interfaces/IAzureEnvironment.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,6 @@ public interface IAzureEnvironment : IExtensibleModel
122122
/// </summary>
123123
string AzureDataLakeStoreFileSystemEndpointSuffix { get; set; }
124124

125-
/// <summary>
126-
/// The token audience required for communicating with the Azure Log Analytics query service in this environment
127-
/// </summary>
128-
string AzureOperationalInsightsEndpointResourceId { get; set; }
129-
130-
/// <summary>
131-
/// The endpoint to use when communicating with the Azure Log Analytics query service in this environment
132-
/// </summary>
133-
string AzureOperationalInsightsEndpoint { get; set; }
134-
135125
/// <summary>
136126
/// The default Active Directory Tenant
137127
/// </summary>

src/ResourceManager/Common/Commands.Common.Authentication.ResourceManager/Models/PSAzureEnvironment.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,32 @@ public bool OnPremise
230230
/// <summary>
231231
/// The token audience required for communicating with the Azure Log Analytics query service in this environment
232232
/// </summary>
233-
public string AzureOperationalInsightsEndpointResourceId { get; set; }
233+
public string AzureOperationalInsightsEndpointResourceId
234+
{
235+
get
236+
{
237+
return this.GetEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId);
238+
}
239+
set
240+
{
241+
this.SetEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, value);
242+
}
243+
}
234244

235245
/// <summary>
236246
/// The endpoint to use when communicating with the Azure Log Analytics query service in this environment
237247
/// </summary>
238-
public string AzureOperationalInsightsEndpoint { get; set; }
248+
public string AzureOperationalInsightsEndpoint
249+
{
250+
get
251+
{
252+
return this.GetEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint);
253+
}
254+
set
255+
{
256+
this.SetEndpoint(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, value);
257+
}
258+
}
239259

240260
public IList<string> VersionProfiles { get; } = new List<string>();
241261

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Query/InvokeOperationalInsightsQuery.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal OperationalInsightsDataClient OperationalInsightsDataClient
6363
}
6464
else
6565
{
66-
clientCredentials = AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(DefaultContext, "AzureOperationalInsightsEndpointResourceId");
66+
clientCredentials = AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(DefaultContext, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint);
6767
}
6868

6969
this._operationalInsightsDataClient =
@@ -74,7 +74,7 @@ internal OperationalInsightsDataClient OperationalInsightsDataClient
7474

7575
Uri targetUri= null;
7676
DefaultContext.Environment.TryGetEndpointUrl(
77-
AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint, out targetUri);
77+
AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, out targetUri);
7878
if (targetUri == null)
7979
{
8080
throw new Exception("Operational Insights is not supported in this Azure Environment");

src/ResourceManager/Profile/Commands.Profile/Environment/AddAzureRMEnvironment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ public override void ExecuteCmdlet()
300300
nameof(DataLakeAudience));
301301
SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.BatchEndpointResourceId,
302302
nameof(BatchEndpointResourceId));
303-
SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId,
303+
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId,
304304
nameof(AzureOperationalInsightsEndpointResourceId));
305-
SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint,
305+
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint,
306306
nameof(AzureOperationalInsightsEndpoint));
307307
WriteObject(new PSAzureEnvironment(profileClient.AddOrSetEnvironment(newEnvironment)));
308308
}

src/ResourceManager/Profile/Commands.Profile/Environment/SetAzureRMEnvironment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ public override void ExecuteCmdlet()
301301
nameof(DataLakeAudience));
302302
SetEndpointIfBound(newEnvironment, AzureEnvironment.Endpoint.BatchEndpointResourceId,
303303
nameof(BatchEndpointResourceId));
304-
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureOperationalInsightsEndpointResourceId,
304+
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId,
305305
nameof(AzureOperationalInsightsEndpointResourceId));
306-
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureOperationalInsightsEndpoint,
306+
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint,
307307
nameof(AzureOperationalInsightsEndpoint));
308308
WriteObject(new PSAzureEnvironment(profileClient.AddOrSetEnvironment(newEnvironment)));
309309
}

0 commit comments

Comments
 (0)