Skip to content

Commit 4d68fed

Browse files
Update tenant id in DefaultContext using value from json
1 parent 2e16333 commit 4d68fed

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Sql/Sql.Test/ScenarioTests/SqlTestsBase.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
using CommonMonitor = Microsoft.Azure.Management.Monitor.Version2018_09_01;
3434
using Microsoft.Azure.Management.KeyVault;
3535
using Microsoft.Azure.Graph.RBAC;
36+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
3637

3738
namespace Microsoft.Azure.Commands.ScenarioTest.SqlTests
3839
{
@@ -85,8 +86,8 @@ protected void RunPowerShellTest(params string[] scripts)
8586
// Enable undo functionality as well as mock recording
8687
using (var context = MockContext.Start(callingClassType, mockName))
8788
{
88-
SetupManagementClients(context);
8989
Helper.SetupEnvironment(AzureModule.AzureResourceManager);
90+
SetupManagementClients(context);
9091
Helper.SetupModules(AzureModule.AzureResourceManager,
9192
"ScenarioTests\\Common.ps1",
9293
"ScenarioTests\\" + GetType().Name + ".ps1",
@@ -159,6 +160,13 @@ protected Microsoft.Azure.Graph.RBAC.Version1_6.GraphRbacManagementClient GetGra
159160
}
160161
}
161162
graphClient.TenantID = tenantId;
163+
if (AzureRmProfileProvider.Instance != null &&
164+
AzureRmProfileProvider.Instance.Profile != null &&
165+
AzureRmProfileProvider.Instance.Profile.DefaultContext != null &&
166+
AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant != null)
167+
{
168+
AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Id = tenantId;
169+
}
162170
return graphClient;
163171
}
164172

0 commit comments

Comments
 (0)