Skip to content

Commit 32355b2

Browse files
authored
Merge pull request #4923 from ro-joowan/datalake-audience
[ADL] - Fixing AzureEnvironment to use DataLake audience
2 parents fca0a14 + f95f981 commit 32355b2

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class AzureEnvironment : IAzureEnvironment
7777
AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants.ChinaKeyVaultServiceEndpointResourceId,
7878
AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = null,
7979
AzureDataLakeStoreFileSystemEndpointSuffix = null,
80+
DataLakeEndpointResourceId = null,
8081
GraphEndpointResourceId = AzureEnvironmentConstants.ChinaGraphEndpoint,
8182
BatchEndpointResourceId = AzureEnvironmentConstants.ChinaBatchEndpointResourceId,
8283
AdTenant = "Common"
@@ -102,6 +103,7 @@ public class AzureEnvironment : IAzureEnvironment
102103
AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants.USGovernmentKeyVaultServiceEndpointResourceId,
103104
AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = null,
104105
AzureDataLakeStoreFileSystemEndpointSuffix = null,
106+
DataLakeEndpointResourceId = null,
105107
GraphEndpointResourceId = AzureEnvironmentConstants.USGovernmentGraphEndpoint,
106108
BatchEndpointResourceId = AzureEnvironmentConstants.USGovernmentBatchEndpointResourceId,
107109
AdTenant = "Common"
@@ -127,6 +129,7 @@ public class AzureEnvironment : IAzureEnvironment
127129
AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants.GermanAzureKeyVaultServiceEndpointResourceId,
128130
AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = null,
129131
AzureDataLakeStoreFileSystemEndpointSuffix = null,
132+
DataLakeEndpointResourceId = null,
130133
GraphEndpointResourceId = AzureEnvironmentConstants.GermanGraphEndpoint,
131134
BatchEndpointResourceId = AzureEnvironmentConstants.GermanBatchEndpointResourceId,
132135
AdTenant = "Common"

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ public static bool TryGetEndpointString(this IAzureEnvironment environment, stri
120120
case AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix:
121121
propertyValue = environment.AzureDataLakeStoreFileSystemEndpointSuffix;
122122
break;
123+
case AzureEnvironment.Endpoint.DataLakeEndpointResourceId:
124+
propertyValue = environment.DataLakeEndpointResourceId;
125+
break;
123126
case AzureEnvironment.Endpoint.ActiveDirectory:
124127
propertyValue = environment.ActiveDirectoryAuthority;
125128
break;
@@ -444,6 +447,10 @@ public static void CopyFrom(this IAzureEnvironment environment, IAzureEnvironmen
444447
environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix =
445448
other.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix;
446449
}
450+
if (other.IsEndpointSet(AzureEnvironment.Endpoint.DataLakeEndpointResourceId))
451+
{
452+
environment.DataLakeEndpointResourceId = other.DataLakeEndpointResourceId;
453+
}
447454
if (other.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId))
448455
{
449456
environment.AzureKeyVaultServiceEndpointResourceId =
@@ -540,6 +547,10 @@ public static void Update(this IAzureEnvironment environment, IAzureEnvironment
540547
environment.AzureKeyVaultServiceEndpointResourceId =
541548
other.AzureKeyVaultServiceEndpointResourceId;
542549
}
550+
if (other.IsEndpointSet(AzureEnvironment.Endpoint.DataLakeEndpointResourceId))
551+
{
552+
environment.DataLakeEndpointResourceId = other.DataLakeEndpointResourceId;
553+
}
543554

544555
foreach (var profile in other.VersionProfiles)
545556
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public PSAzureEnvironment(PSObject other)
9393
AdTenant = other.GetProperty<string>(nameof(AdTenant));
9494
AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = other.GetProperty<string>(nameof(AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix));
9595
AzureDataLakeStoreFileSystemEndpointSuffix = other.GetProperty<string>(nameof(AzureDataLakeStoreFileSystemEndpointSuffix));
96+
DataLakeEndpointResourceId = other.GetProperty<string>(nameof(DataLakeEndpointResourceId));
9697
AzureKeyVaultDnsSuffix = other.GetProperty<string>(nameof(AzureKeyVaultDnsSuffix));
9798
AzureKeyVaultServiceEndpointResourceId = other.GetProperty<string>(nameof(AzureKeyVaultServiceEndpointResourceId));
9899
BatchEndpointResourceId = other.GetProperty<string>(nameof(BatchEndpointResourceId));
99-
DataLakeEndpointResourceId = other.GetProperty<string>(nameof(DataLakeEndpointResourceId));
100100
GalleryUrl = other.GetProperty<string>(nameof(GalleryUrl));
101101
GraphEndpointResourceId = other.GetProperty<string>(nameof(GraphEndpointResourceId));
102102
GraphUrl = other.GetProperty<string>(nameof(GraphUrl));
@@ -259,6 +259,7 @@ public override bool Equals(object obj)
259259
&& SqlDatabaseDnsSuffix == other.SqlDatabaseDnsSuffix
260260
&& AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix == other.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix
261261
&& AzureDataLakeStoreFileSystemEndpointSuffix == other.AzureDataLakeStoreFileSystemEndpointSuffix
262+
&& DataLakeEndpointResourceId == other.DataLakeEndpointResourceId
262263
&& TrafficManagerDnsSuffix == other.TrafficManagerDnsSuffix
263264
&& BatchEndpointResourceId == other.BatchEndpointResourceId;
264265
}

src/ResourceManager/Profile/Commands.Profile.Test/EnvironmentCmdletTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ public void CanCreateEnvironmentWithAllProperties()
371371
SqlDatabaseDnsSuffix = "SqlDatabaseDnsSuffix",
372372
TrafficManagerDnsSuffix = "TrafficManagerDnsSuffix",
373373
GraphAudience = "GaraphAudience",
374-
BatchEndpointResourceId = "BatchResourceId"
374+
BatchEndpointResourceId = "BatchResourceId",
375+
DataLakeAudience = "DataLakeAudience"
375376
};
376377

377378
var dict = new Dictionary<string, object>();
@@ -392,6 +393,7 @@ public void CanCreateEnvironmentWithAllProperties()
392393
dict["TrafficManagerDnsSuffix"] = "TrafficManagerDnsSuffix";
393394
dict["GraphAudience"] = "GaraphAudience";
394395
dict["BatchEndpointResourceId"] = "BatchResourceId";
396+
dict["DataLakeAudience"] = "DataLakeAudience";
395397
cmdlet.SetBoundParameters(dict);
396398

397399
cmdlet.InvokeBeginProcessing();
@@ -416,6 +418,7 @@ public void CanCreateEnvironmentWithAllProperties()
416418
Assert.Equal(cmdlet.TrafficManagerDnsSuffix, actual.TrafficManagerDnsSuffix);
417419
Assert.Equal(cmdlet.GraphAudience, actual.GraphEndpointResourceId);
418420
Assert.Equal(cmdlet.BatchEndpointResourceId, actual.BatchEndpointResourceId);
421+
Assert.Equal(cmdlet.DataLakeAudience, actual.DataLakeEndpointResourceId);
419422
commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<PSAzureEnvironment>()), Times.Once());
420423
IAzureEnvironment env = AzureRmProfileProvider.Instance.Profile.GetEnvironment("KaTaL");
421424
Assert.Equal(env.Name, cmdlet.Name);

src/ResourceManager/Profile/Commands.Profile.Test/TypeConversionTests.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void CanConvertNullEnvironments()
4141
Assert.Null(environment.AdTenant);
4242
Assert.Null(environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix);
4343
Assert.Null(environment.AzureDataLakeStoreFileSystemEndpointSuffix);
44+
Assert.Null(environment.DataLakeEndpointResourceId);
4445
Assert.Null(environment.AzureKeyVaultDnsSuffix);
4546
Assert.Null(environment.AzureKeyVaultServiceEndpointResourceId);
4647
Assert.False(environment.EnableAdfsAuthentication);
@@ -65,19 +66,19 @@ public void CanConvertNullEnvironments()
6566
"https://graph.windows.net", "https://graph.windows.net/", "https://manage.windowsazure.com",
6667
"https://manage.windowsazure.com/publishsettings", "https://management.azure.com",
6768
"https://management.core.windows.net", ".sql.azure.com", ".core.windows.net",
68-
".trafficmanager.windows.net", "https://batch.core.windows.net")]
69+
".trafficmanager.windows.net", "https://batch.core.windows.net", "https://datalake.azure.net")]
6970
[Trait(Category.AcceptanceType, Category.CheckIn)]
7071
public void CanConvertValidEnvironments(string name, bool onPremise, string activeDirectory, string serviceResource,
7172
string adTenant, string dataLakeJobs, string dataLakeFiles, string kvDnsSuffix,
7273
string kvResource, string gallery, string graph, string graphResource, string portal,
7374
string publishSettings, string resourceManager, string serviceManagement,
74-
string sqlSuffix, string storageSuffix, string trafficManagerSuffix, string batchResource)
75+
string sqlSuffix, string storageSuffix, string trafficManagerSuffix, string batchResource, string dataLakeResource)
7576
{
7677
AzureEnvironment azEnvironment = CreateEnvironment(name, onPremise, activeDirectory,
7778
serviceResource, adTenant, dataLakeJobs, dataLakeFiles, kvDnsSuffix,
7879
kvResource, gallery, graph, graphResource, portal, publishSettings,
7980
resourceManager, serviceManagement, sqlSuffix, storageSuffix,
80-
trafficManagerSuffix, batchResource);
81+
trafficManagerSuffix, batchResource, dataLakeResource);
8182
var environment = (PSAzureEnvironment)azEnvironment;
8283
Assert.NotNull(environment);
8384
CheckEndpoint(AzureEnvironment.Endpoint.ActiveDirectory, azEnvironment,
@@ -90,6 +91,8 @@ public void CanConvertValidEnvironments(string name, bool onPremise, string acti
9091
environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix);
9192
CheckEndpoint(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix, azEnvironment,
9293
environment.AzureDataLakeStoreFileSystemEndpointSuffix);
94+
CheckEndpoint(AzureEnvironment.Endpoint.DataLakeEndpointResourceId, azEnvironment,
95+
environment.DataLakeEndpointResourceId);
9396
CheckEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, azEnvironment,
9497
environment.AzureKeyVaultDnsSuffix);
9598
CheckEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, azEnvironment,
@@ -133,6 +136,7 @@ public void CanConvertNullPSEnvironments()
133136
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AdTenant));
134137
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix));
135138
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix));
139+
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.DataLakeEndpointResourceId));
136140
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix));
137141
Assert.False(environment.IsEndpointSet(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId));
138142
Assert.False(environment.OnPremise);
@@ -156,13 +160,13 @@ public void CanConvertNullPSEnvironments()
156160
"https://graph.windows.net", "https://graph.windows.net/", "https://manage.windowsazure.com",
157161
"https://manage.windowsazure.com/publishsettings", "https://management.azure.com",
158162
"https://management.core.windows.net", ".sql.azure.com", ".core.windows.net",
159-
".trafficmanager.windows.net", "https://batch.core.windows.net")]
163+
".trafficmanager.windows.net", "https://batch.core.windows.net", "https://datalake.azure.net")]
160164
[Trait(Category.AcceptanceType, Category.CheckIn)]
161165
public void CanConvertValidPSEnvironments(string name, bool onPremise, string activeDirectory, string serviceResource,
162166
string adTenant, string dataLakeJobs, string dataLakeFiles, string kvDnsSuffix,
163167
string kvResource, string gallery, string graph, string graphResource, string portal,
164168
string publishSettings, string resourceManager, string serviceManagement,
165-
string sqlSuffix, string storageSuffix, string trafficManagerSuffix, string batchResource)
169+
string sqlSuffix, string storageSuffix, string trafficManagerSuffix, string batchResource, string dataLakeResource)
166170
{
167171
PSAzureEnvironment environment = new PSAzureEnvironment
168172
{
@@ -173,6 +177,7 @@ public void CanConvertValidPSEnvironments(string name, bool onPremise, string ac
173177
AdTenant = adTenant,
174178
AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = dataLakeJobs,
175179
AzureDataLakeStoreFileSystemEndpointSuffix = dataLakeFiles,
180+
DataLakeEndpointResourceId = dataLakeResource,
176181
AzureKeyVaultDnsSuffix = kvDnsSuffix,
177182
AzureKeyVaultServiceEndpointResourceId = kvResource,
178183
GalleryUrl = gallery,
@@ -199,6 +204,8 @@ public void CanConvertValidPSEnvironments(string name, bool onPremise, string ac
199204
environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix);
200205
CheckEndpoint(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix, azEnvironment,
201206
environment.AzureDataLakeStoreFileSystemEndpointSuffix);
207+
CheckEndpoint(AzureEnvironment.Endpoint.DataLakeEndpointResourceId, azEnvironment,
208+
environment.DataLakeEndpointResourceId);
202209
CheckEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, azEnvironment,
203210
environment.AzureKeyVaultDnsSuffix);
204211
CheckEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, azEnvironment,
@@ -234,7 +241,7 @@ private AzureEnvironment CreateEnvironment(string name, bool onPremise, string a
234241
string adTenant, string dataLakeJobs, string dataLakeFiles, string kvDnsSuffix,
235242
string kvResource, string gallery, string graph, string graphResource, string portal,
236243
string publishSettings, string resourceManager, string serviceManagement,
237-
string sqlSuffix, string storageSuffix, string trafficManagerSuffix, string batchResource)
244+
string sqlSuffix, string storageSuffix, string trafficManagerSuffix, string batchResource, string dataLakeResource)
238245
{
239246
var environment = new AzureEnvironment() { Name = name, OnPremise = onPremise };
240247
SetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory, environment, activeDirectory);
@@ -248,6 +255,9 @@ private AzureEnvironment CreateEnvironment(string name, bool onPremise, string a
248255
CheckEndpoint(AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix,
249256
environment,
250257
dataLakeFiles);
258+
CheckEndpoint(AzureEnvironment.Endpoint.DataLakeEndpointResourceId,
259+
environment,
260+
dataLakeResource);
251261
CheckEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, environment,
252262
kvDnsSuffix);
253263
CheckEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId,

0 commit comments

Comments
 (0)