-
Notifications
You must be signed in to change notification settings - Fork 56
/
AzureEnvironmentExtensions.cs
598 lines (565 loc) · 29.2 KB
/
AzureEnvironmentExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------
using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Properties;
using System;
namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions
{
/// <summary>
/// Convenience methods for environments
/// </summary>
public static class AzureEnvironmentExtensions
{
/// <summary>
/// Try to get the uri from the environment mathcing the given name
/// </summary>
/// <param name="environment">The environment to get the value from</param>
/// <param name="endpointName">The name of the endpoint to attempt to get</param>
/// <param name="endpoint">The returned endpoint value as a Uri, or null if no endpoint was found</param>
/// <returns>true if the endpoint was found, otherwise false</returns>
public static bool TryGetEndpointUrl(this IAzureEnvironment environment, string endpointName, out Uri endpoint)
{
bool result = true;
endpoint = null;
switch(endpointName)
{
case AzureEnvironment.Endpoint.ActiveDirectory:
endpoint = new Uri(environment.ActiveDirectoryAuthority);
break;
case AzureEnvironment.Endpoint.Gallery:
endpoint = new Uri(environment.GalleryUrl);
break;
case AzureEnvironment.Endpoint.Graph:
endpoint = new Uri(environment.GraphUrl);
break;
case AzureEnvironment.Endpoint.ManagementPortalUrl:
endpoint = new Uri(environment.ManagementPortalUrl);
break;
case AzureEnvironment.Endpoint.PublishSettingsFileUrl:
endpoint = new Uri(environment.PublishSettingsFileUrl);
break;
case AzureEnvironment.Endpoint.ResourceManager:
endpoint = new Uri(environment.ResourceManagerUrl);
break;
case AzureEnvironment.Endpoint.ServiceManagement:
endpoint = new Uri(environment.ServiceManagementUrl);
break;
case AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId:
endpoint = new Uri(environment.ActiveDirectoryServiceEndpointResourceId);
break;
case AzureEnvironment.Endpoint.GraphEndpointResourceId:
endpoint = new Uri(environment.GraphEndpointResourceId);
break;
case AzureEnvironment.Endpoint.DataLakeEndpointResourceId:
endpoint = new Uri(environment.DataLakeEndpointResourceId);
break;
case AzureEnvironment.Endpoint.BatchEndpointResourceId:
endpoint = new Uri(environment.BatchEndpointResourceId);
break;
default:
result = environment.IsPropertySet(endpointName);
if (result)
{
endpoint = new Uri(environment.GetProperty(endpointName));
}
break;
}
return result;
}
/// <summary>
/// Get non-endpoint values of the environment, such as resource strings and dns suffixes for servides.
/// </summary>
/// <param name="environment">The environment to check for the given property</param>
/// <param name="endpointName">The name of the property to check for</param>
/// <param name="propertyValue">The value of the property, if found in the environment, or null if not found</param>
/// <returns>True if the property value is found in the environment, otherwise false.</returns>
public static bool TryGetEndpointString(this IAzureEnvironment environment, string endpointName, out string propertyValue)
{
propertyValue = null;
if (environment != null)
{
switch (endpointName)
{
case AzureEnvironment.Endpoint.AdTenant:
propertyValue = environment.AdTenant;
break;
case AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId:
propertyValue = environment.ActiveDirectoryServiceEndpointResourceId;
break;
case AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix:
propertyValue = environment.AzureKeyVaultDnsSuffix;
break;
case AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId:
propertyValue = environment.AzureKeyVaultServiceEndpointResourceId;
break;
case AzureEnvironment.Endpoint.GraphEndpointResourceId:
propertyValue = environment.GraphEndpointResourceId;
break;
case AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix:
propertyValue = environment.SqlDatabaseDnsSuffix;
break;
case AzureEnvironment.Endpoint.StorageEndpointSuffix:
propertyValue = environment.StorageEndpointSuffix;
break;
case AzureEnvironment.Endpoint.TrafficManagerDnsSuffix:
propertyValue = environment.TrafficManagerDnsSuffix;
break;
case AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix:
propertyValue = environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix;
break;
case AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix:
propertyValue = environment.AzureDataLakeStoreFileSystemEndpointSuffix;
break;
case AzureEnvironment.Endpoint.DataLakeEndpointResourceId:
propertyValue = environment.DataLakeEndpointResourceId;
break;
case AzureEnvironment.Endpoint.ActiveDirectory:
propertyValue = environment.ActiveDirectoryAuthority;
break;
case AzureEnvironment.Endpoint.Gallery:
propertyValue = environment.GalleryUrl;
break;
case AzureEnvironment.Endpoint.Graph:
propertyValue = environment.GraphUrl;
break;
case AzureEnvironment.Endpoint.ManagementPortalUrl:
propertyValue = environment.ManagementPortalUrl;
break;
case AzureEnvironment.Endpoint.PublishSettingsFileUrl:
propertyValue = environment.PublishSettingsFileUrl;
break;
case AzureEnvironment.Endpoint.ResourceManager:
propertyValue = environment.ResourceManagerUrl;
break;
case AzureEnvironment.Endpoint.ServiceManagement:
propertyValue = environment.ServiceManagementUrl;
break;
case AzureEnvironment.Endpoint.BatchEndpointResourceId:
propertyValue = environment.BatchEndpointResourceId;
break;
default:
// get property from the extended properties of the environment
propertyValue = environment.GetProperty(endpointName);
break;
}
}
return propertyValue != null;
}
/// <summary>
/// Get the url in this environment for the given named endpoint
/// </summary>
/// <param name="environment"></param>
/// <param name="endpoint"></param>
/// <returns>The Uri of the given endpoint, or null if it is not set in the given environment</returns>
public static Uri GetEndpointAsUri(this IAzureEnvironment environment, string endpoint)
{
Uri endpointUri;
if (environment.TryGetEndpointUrl(endpoint, out endpointUri))
{
return endpointUri;
}
return null;
}
/// <summary>
/// Get the string endpoint value from this environemtn for the given named endpoint
/// </summary>
/// <param name="environment">The environemnt to use</param>
/// <param name="endpoint">The endpoint to get from the environemnt.</param>
/// <returns>The value of the given endpoint in the environment if found, or null if not.</returns>
public static string GetEndpoint(this IAzureEnvironment environment, string endpoint)
{
string endpointValue;
if (environment.TryGetEndpointString(endpoint, out endpointValue))
{
return endpointValue;
}
return null;
}
/// <summary>
/// Set the given named endpoint in this environment to the provided value
/// </summary>
/// <param name="environment">The environment to change</param>
/// <param name="endpointName">The named endpoint to update</param>
/// <param name="propertyValue">The value to set the named endpoint to in the given environment</param>
public static void SetEndpoint(this IAzureEnvironment environment, string endpointName, string propertyValue)
{
if (!string.IsNullOrWhiteSpace(propertyValue))
{
switch (endpointName)
{
case AzureEnvironment.Endpoint.AdTenant:
environment.AdTenant = propertyValue;
break;
case AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId:
environment.ActiveDirectoryServiceEndpointResourceId = propertyValue;
break;
case AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix:
environment.AzureKeyVaultDnsSuffix = propertyValue;
break;
case AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId:
environment.AzureKeyVaultServiceEndpointResourceId = propertyValue;
break;
case AzureEnvironment.Endpoint.GraphEndpointResourceId:
environment.GraphEndpointResourceId = propertyValue;
break;
case AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix:
environment.SqlDatabaseDnsSuffix = propertyValue;
break;
case AzureEnvironment.Endpoint.StorageEndpointSuffix:
environment.StorageEndpointSuffix = propertyValue;
break;
case AzureEnvironment.Endpoint.TrafficManagerDnsSuffix:
environment.TrafficManagerDnsSuffix = propertyValue;
break;
case AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix:
environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = propertyValue;
break;
case AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix:
environment.AzureDataLakeStoreFileSystemEndpointSuffix = propertyValue;
break;
case AzureEnvironment.Endpoint.DataLakeEndpointResourceId:
environment.DataLakeEndpointResourceId = propertyValue;
break;
case AzureEnvironment.Endpoint.BatchEndpointResourceId:
environment.BatchEndpointResourceId = propertyValue;
break;
case AzureEnvironment.Endpoint.ActiveDirectory:
environment.ActiveDirectoryAuthority = propertyValue;
break;
case AzureEnvironment.Endpoint.Gallery:
environment.GalleryUrl = propertyValue;
break;
case AzureEnvironment.Endpoint.Graph:
environment.GraphUrl = propertyValue;
break;
case AzureEnvironment.Endpoint.ManagementPortalUrl:
environment.ManagementPortalUrl = propertyValue;
break;
case AzureEnvironment.Endpoint.PublishSettingsFileUrl:
environment.PublishSettingsFileUrl = propertyValue;
break;
case AzureEnvironment.Endpoint.ResourceManager:
environment.ResourceManagerUrl = propertyValue;
break;
case AzureEnvironment.Endpoint.ServiceManagement:
environment.ServiceManagementUrl = propertyValue;
break;
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId:
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId, propertyValue);
break;
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint:
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint, propertyValue);
break;
case AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix:
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix, propertyValue);
break;
}
}
}
/// <summary>
/// Get the token audience for the given named endpoint
/// </summary>
/// <param name="environment">The environment to check</param>
/// <param name="targetEndpoint">The named endpoint to target</param>
/// <returns>The correct token audience for tokens bound for the given endpoint.</returns>
public static string GetTokenAudience(this IAzureEnvironment environment, string targetEndpoint)
{
string resource;
switch (targetEndpoint)
{
case AzureEnvironment.Endpoint.Graph:
resource = AzureEnvironment.Endpoint.GraphEndpointResourceId;
break;
case AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix:
case AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix:
case AzureEnvironment.Endpoint.DataLakeEndpointResourceId:
resource = AzureEnvironment.Endpoint.DataLakeEndpointResourceId;
break;
case AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix:
case AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId:
resource = AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId;
break;
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpoint:
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId:
resource = AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId;
break;
default:
resource = AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId;
break;
}
return resource;
}
/// <summary>
/// Determine if the given endpoint is set in the given environment
/// </summary>
/// <param name="environment">The environment to check</param>
/// <param name="endpoint">The named endpoint to search for</param>
/// <returns>True if the endpoint is set to a non-null value in the environment, otherwise false</returns>
public static bool IsEndpointSet(this IAzureEnvironment environment, string endpoint)
{
string endpointValue;
return environment.TryGetEndpointString(endpoint, out endpointValue);
}
/// <summary>
/// Determine if the given endpoint is set to the provided value
/// </summary>
/// <param name="environment">The environment to search</param>
/// <param name="endpoint">The endpoint to check</param>
/// <param name="url">The value to check for</param>
/// <returns>True if the endpoint is set to the proviuded value, otherwise false</returns>
public static bool IsEndpointSetToValue(this IAzureEnvironment environment, string endpoint, string url)
{
if (url == null && !environment.IsEndpointSet(endpoint))
{
return true;
}
if (url != null && environment.IsEndpointSet(endpoint))
{
return environment.GetEndpoint(endpoint)
.Trim(new[] { '/' })
.Equals(url.Trim(new[] { '/' }), StringComparison.InvariantCultureIgnoreCase);
}
return false;
}
/// <summary>
/// Get the given endpoint suffix in the given environment
/// </summary>
/// <param name="environment">The environment to check</param>
/// <param name="endpointSuffix">The nemaed endpoint suffix to search for</param>
/// <returns>The value of the endpoint suffix, or null if it is not set</returns>
public static string GetEndpointSuffix(this IAzureEnvironment environment, string endpointSuffix)
{
string suffix;
if (environment.TryGetEndpointString(endpointSuffix, out suffix))
{
return suffix;
}
return null;
}
/// <summary>
/// Gets the management portal URI with a particular realm suffix if supplied
/// </summary>
/// <param name="realm">Realm for user's account</param>
/// <returns>Url to management portal.</returns>
public static string GetManagementPortalUrlWithRealm(this IAzureEnvironment environment, string realm = null)
{
if (realm != null)
{
realm = string.Format(Resources.PublishSettingsFileRealmFormat, realm);
}
else
{
realm = string.Empty;
}
return environment.ManagementPortalUrl + realm;
}
/// <summary>
/// Get the publish settings file download url with a realm suffix if needed.
/// </summary>
/// <param name="realm">Realm for user's account</param>
/// <returns>Url to publish settings file</returns>
public static string GetPublishSettingsFileUrlWithRealm(this IAzureEnvironment environment, string realm = null)
{
if (realm != null)
{
realm = string.Format(Resources.PublishSettingsFileRealmFormat, realm);
}
else
{
realm = string.Empty;
}
return environment.PublishSettingsFileUrl + realm;
}
public static void CopyFrom(this IAzureEnvironment environment, IAzureEnvironment other)
{
if (environment != null && other != null)
{
environment.Name = other.Name;
environment.OnPremise = other.OnPremise;
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId))
{
environment.ActiveDirectoryServiceEndpointResourceId = other.ActiveDirectoryServiceEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AdTenant))
{
environment.AdTenant = other.AdTenant;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.Gallery))
{
environment.GalleryUrl = other.GalleryUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ManagementPortalUrl))
{
environment.ManagementPortalUrl = other.ManagementPortalUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ServiceManagement))
{
environment.ServiceManagementUrl = other.ServiceManagementUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.PublishSettingsFileUrl))
{
environment.PublishSettingsFileUrl = other.PublishSettingsFileUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ResourceManager))
{
environment.ResourceManagerUrl = other.ResourceManagerUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix))
{
environment.SqlDatabaseDnsSuffix = other.SqlDatabaseDnsSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.StorageEndpointSuffix))
{
environment.StorageEndpointSuffix = other.StorageEndpointSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ActiveDirectory))
{
environment.ActiveDirectoryAuthority = other.ActiveDirectoryAuthority;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.Graph))
{
environment.GraphUrl = other.GraphUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.GraphEndpointResourceId))
{
environment.GraphEndpointResourceId = other.GraphEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.TrafficManagerDnsSuffix))
{
environment.TrafficManagerDnsSuffix = other.TrafficManagerDnsSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix))
{
environment.AzureKeyVaultDnsSuffix = other.AzureKeyVaultDnsSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix))
{
environment.AzureDataLakeStoreFileSystemEndpointSuffix = other.AzureDataLakeStoreFileSystemEndpointSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix))
{
environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix =
other.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.DataLakeEndpointResourceId))
{
environment.DataLakeEndpointResourceId = other.DataLakeEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId))
{
environment.AzureKeyVaultServiceEndpointResourceId =
other.AzureKeyVaultServiceEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.BatchEndpointResourceId))
{
environment.BatchEndpointResourceId = other.BatchEndpointResourceId;
}
environment.VersionProfiles.Clear();
foreach (var profile in other.VersionProfiles)
{
environment.VersionProfiles.Add(profile);
}
environment.CopyPropertiesFrom(other);
}
}
public static void Update(this IAzureEnvironment environment, IAzureEnvironment other)
{
if (environment != null && other != null)
{
environment.OnPremise = other.OnPremise;
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId))
{
environment.ActiveDirectoryServiceEndpointResourceId = other.ActiveDirectoryServiceEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AdTenant))
{
environment.AdTenant = other.AdTenant;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.Gallery))
{
environment.GalleryUrl = other.GalleryUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ManagementPortalUrl))
{
environment.ManagementPortalUrl = other.ManagementPortalUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ServiceManagement))
{
environment.ServiceManagementUrl = other.ServiceManagementUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.PublishSettingsFileUrl))
{
environment.PublishSettingsFileUrl = other.PublishSettingsFileUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ResourceManager))
{
environment.ResourceManagerUrl = other.ResourceManagerUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix))
{
environment.SqlDatabaseDnsSuffix = other.SqlDatabaseDnsSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.StorageEndpointSuffix))
{
environment.StorageEndpointSuffix = other.StorageEndpointSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.ActiveDirectory))
{
environment.ActiveDirectoryAuthority = other.ActiveDirectoryAuthority;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.Graph))
{
environment.GraphUrl = other.GraphUrl;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.GraphEndpointResourceId))
{
environment.GraphEndpointResourceId = other.GraphEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.TrafficManagerDnsSuffix))
{
environment.TrafficManagerDnsSuffix = other.TrafficManagerDnsSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix))
{
environment.AzureKeyVaultDnsSuffix = other.AzureKeyVaultDnsSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix))
{
environment.AzureDataLakeStoreFileSystemEndpointSuffix = other.AzureDataLakeStoreFileSystemEndpointSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix))
{
environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix =
other.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId))
{
environment.AzureKeyVaultServiceEndpointResourceId =
other.AzureKeyVaultServiceEndpointResourceId;
}
if (other.IsEndpointSet(AzureEnvironment.Endpoint.DataLakeEndpointResourceId))
{
environment.DataLakeEndpointResourceId = other.DataLakeEndpointResourceId;
}
foreach (var profile in other.VersionProfiles)
{
if (!environment.VersionProfiles.Contains(profile))
{
environment.VersionProfiles.Add(profile);
}
}
environment.UpdateProperties(other);
}
}
}
}