Skip to content

Commit c1c3ecf

Browse files
Az.StorageSync - Migrate AAD to MSGraph (#16996)
* First Draft for making changes of msgraph * MsGraph : Record tests * Update TestRegisteredServer.json Co-authored-by: Yabo Hu <[email protected]>
1 parent 01158db commit c1c3ecf

34 files changed

+13341
-12635
lines changed

src/StorageSync/StorageSync.Test/Common/MockStorageSyncResourceManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Commands.StorageSync.Interop.Clients;
1616
using Commands.StorageSync.Interop.DataObjects;
1717
using Commands.StorageSync.Interop.Interfaces;
18+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
1819
using Microsoft.Azure.Commands.StorageSync.Common;
1920
using Microsoft.Azure.Commands.StorageSync.Interfaces;
2021
using Microsoft.Azure.Test.HttpRecorder;
@@ -150,5 +151,11 @@ public string GetTenantId()
150151
}
151152
return tenantId;
152153
}
154+
155+
/// <summary>
156+
/// Get Service Principal Or Null
157+
/// </summary>
158+
/// <returns>MicrosoftGraphServicePrincipal</returns>
159+
public MicrosoftGraphServicePrincipal GetServicePrincipalOrNull() => new MicrosoftGraphServicePrincipal() { Id = "384dab06-7a70-4ecf-a04e-284602199124" }; // Change Object ID if we are using some other tenant
153160
}
154161
}

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestCloudEndpoint.json

Lines changed: 776 additions & 1697 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestGetCloudEndpoint.json

Lines changed: 417 additions & 1128 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestGetCloudEndpointParentObject.json

Lines changed: 369 additions & 855 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestGetCloudEndpointParentResourceId.json

Lines changed: 376 additions & 832 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestGetCloudEndpoints.json

Lines changed: 594 additions & 588 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestNewCloudEndpoint.json

Lines changed: 715 additions & 511 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestRemoveCloudEndpoint.json

Lines changed: 515 additions & 740 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestRemoveCloudEndpointInputObject.json

Lines changed: 1341 additions & 573 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.CloudEndpointTests/TestRemoveCloudEndpointResourceId.json

Lines changed: 3230 additions & 548 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestGetRegisteredServer.json

Lines changed: 417 additions & 369 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestGetRegisteredServerParentObject.json

Lines changed: 257 additions & 371 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestGetRegisteredServerParentResourceId.json

Lines changed: 263 additions & 377 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestGetRegisteredServers.json

Lines changed: 272 additions & 338 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestNewRegisteredServer.json

Lines changed: 262 additions & 376 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestNewRegisteredServerParentObject.json

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

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestNewRegisteredServerParentResourceId.json

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

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestRegisteredServer.json

Lines changed: 689 additions & 407 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestRegisteredServerPipeline1.json

Lines changed: 407 additions & 359 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestRegisteredServerPipeline2.json

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

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestRemoveRegisteredServer.json

Lines changed: 479 additions & 251 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestRemoveRegisteredServerInputObject.json

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

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.RegisteredServerTests/TestRemoveRegisteredServerResourceId.json

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

src/StorageSync/StorageSync.Test/SessionRecords/StorageSyncTests.ServerEndpointTests/TestServerEndpoint.json

Lines changed: 549 additions & 894 deletions
Large diffs are not rendered by default.

src/StorageSync/StorageSync.Test/TestController.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
17+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0;
1718
using Microsoft.Azure.Commands.StorageSync.Common;
1819
using Microsoft.Azure.Commands.StorageSync.Interfaces;
19-
using Microsoft.Azure.Graph.RBAC.Version1_6_20190326;
2020
using Microsoft.Azure.Management.Authorization.Version2015_07_01;
2121
using Microsoft.Azure.Management.Internal.Resources;
2222
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01;
@@ -185,17 +185,17 @@ private void SetupManagementClients(MockContext context)
185185
var subClient = context.GetServiceClient<SubscriptionClient>(TestEnvironmentFactory.GetTestEnvironment());
186186
var storageSyncClient = context.GetServiceClient<StorageSyncManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
187187
var storageClient = context.GetServiceClient<StorageManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
188-
GraphRbacManagementClient rbacClient = GetGraphClient(context);
188+
MicrosoftGraphClient microsoftGraphClient = GetGraphClient(context);
189189
var authClient = context.GetServiceClient<AuthorizationManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
190-
_helper.SetupManagementClients(rmClient, subClient, storageSyncClient, storageClient, rbacClient, authClient);
190+
_helper.SetupManagementClients(rmClient, subClient, storageSyncClient, storageClient, microsoftGraphClient, authClient);
191191
}
192192

193193
/// <summary>
194194
/// Gets the graph client.
195195
/// </summary>
196196
/// <param name="context">The context.</param>
197-
/// <returns>GraphRbacManagementClient.</returns>
198-
private GraphRbacManagementClient GetGraphClient(MockContext context)
197+
/// <returns>MicrosoftGraphClient.</returns>
198+
private MicrosoftGraphClient GetGraphClient(MockContext context)
199199
{
200200
var environment = TestEnvironmentFactory.GetTestEnvironment();
201201
string tenantId = null;
@@ -224,7 +224,7 @@ private GraphRbacManagementClient GetGraphClient(MockContext context)
224224
}
225225
}
226226

227-
var client = context.GetGraphServiceClient<GraphRbacManagementClient>(environment);
227+
var client = context.GetGraphServiceClient<MicrosoftGraphClient>(environment, true);
228228
client.TenantID = tenantId;
229229
if (AzureRmProfileProvider.Instance != null &&
230230
AzureRmProfileProvider.Instance.Profile != null &&

src/StorageSync/StorageSync/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Migrated Azure AD features in Az.StorageSync to MSGraph APIs. The cmdlets will call MSGraph API according to input parameters: New-AzStorageSyncCloudEndpoint
2122
* Changed default parameter set of Invoke-AzStorageSyncChangeDetection to use full share detection
2223

2324
## Version 1.6.1

src/StorageSync/StorageSync/CloudEndpoint/NewCloudEndpointCommand.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
1516
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1617
using Microsoft.Azure.Commands.StorageSync.Common;
1718

1819
using Microsoft.Azure.Commands.StorageSync.Common.Extensions;
1920
using Microsoft.Azure.Commands.StorageSync.Models;
2021
using Microsoft.Azure.Commands.StorageSync.Properties;
21-
using Microsoft.Azure.Graph.RBAC.Version1_6_20190326.ActiveDirectory;
2222
using Microsoft.Azure.Management.Authorization.Version2015_07_01.Models;
2323
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2424
using Microsoft.Azure.Management.StorageSync;
@@ -211,7 +211,12 @@ public override void ExecuteCmdlet()
211211
}
212212
}
213213

214-
PSADServicePrincipal servicePrincipal = StorageSyncClientWrapper.EnsureServicePrincipal();
214+
MicrosoftGraphServicePrincipal servicePrincipal = StorageSyncClientWrapper.GetServicePrincipalOrNull();
215+
216+
if (servicePrincipal == null)
217+
{
218+
throw new PSArgumentException(StorageSyncResources.MissingServicePrincipalResourceIdErrorMessage);
219+
}
215220
RoleAssignment roleAssignment = StorageSyncClientWrapper.EnsureRoleAssignment(servicePrincipal, storageAccountResourceIdentifier.Subscription, StorageAccountResourceId);
216221

217222
var parentResourceIdentifier = default(ResourceIdentifier);

src/StorageSync/StorageSync/Common/StorageSyncClientCmdletBase.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Authentication;
1516
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
17+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0;
18+
using Microsoft.Azure.Commands.ResourceManager.Common;
1619
using Microsoft.Azure.Commands.ResourceManager.Common.Properties;
1720
using Microsoft.Azure.Commands.StorageSync.Common.Converters;
1821
using Microsoft.Azure.Commands.StorageSync.Common.Exceptions;
1922
using Microsoft.Azure.Commands.StorageSync.Interfaces;
20-
using Microsoft.Azure.Graph.RBAC.Version1_6_20190326.ActiveDirectory;
23+
using Microsoft.Rest;
2124
using System;
2225
using System.Collections.Generic;
2326
using System.Linq;
@@ -40,13 +43,20 @@ public interface IStorageSyncClientCmdlet
4043

4144
/// <summary>
4245
/// Class StorageSyncClientCmdletBase.
43-
/// Implements the <see cref="Microsoft.Azure.Graph.RBAC.Version1_6_20190326.ActiveDirectory.ActiveDirectoryBaseCmdlet" />
4446
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Common.IStorageSyncClientCmdlet" />
4547
/// </summary>
46-
/// <seealso cref="Microsoft.Azure.Graph.RBAC.Version1_6_20190326.ActiveDirectory.ActiveDirectoryBaseCmdlet" />
4748
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Common.IStorageSyncClientCmdlet" />
48-
public abstract class StorageSyncClientCmdletBase : ActiveDirectoryBaseCmdlet, IStorageSyncClientCmdlet
49+
public abstract class StorageSyncClientCmdletBase : AzureRMCmdlet, IStorageSyncClientCmdlet
4950
{
51+
private MicrosoftGraphClient microsoftGraphClient;
52+
53+
public MicrosoftGraphClient MicrosoftGraphClient =>
54+
microsoftGraphClient ?? (microsoftGraphClient = BuildClient<MicrosoftGraphClient>(endpoint: AzureEnvironment.ExtendedEndpoint.MicrosoftGraphUrl, postBuild: instance =>
55+
{
56+
instance.TenantID = DefaultContext.Tenant.Id;
57+
return instance;
58+
}));
59+
5060
/// <summary>
5161
/// The production arm service host
5262
/// </summary>
@@ -131,7 +141,7 @@ public IStorageSyncClientWrapper StorageSyncClientWrapper
131141
{
132142
if (storageSyncClientWrapper == null)
133143
{
134-
storageSyncClientWrapper = new StorageSyncClientWrapper(AzureContext, ActiveDirectoryClient);
144+
storageSyncClientWrapper = new StorageSyncClientWrapper(AzureContext, MicrosoftGraphClient);
135145
}
136146

137147
storageSyncClientWrapper.VerboseLogger = WriteVerboseWithTimestamp;
@@ -262,5 +272,12 @@ protected void WriteObject(IEnumerable<StorageSyncModels.ServerEndpoint> resourc
262272
{
263273
WriteObject(resources.Select(new ServerEndpointConverter().Convert), true);
264274
}
275+
276+
private T BuildClient<T>(string endpoint = null, Func<T, T> postBuild = null) where T : ServiceClient<T>
277+
{
278+
var instance = AzureSession.Instance.ClientFactory.CreateArmClient<T>(
279+
DefaultProfile.DefaultContext, endpoint ?? AzureEnvironment.Endpoint.ResourceManager);
280+
return postBuild == null ? instance : postBuild(instance);
281+
}
265282
}
266283
}

src/StorageSync/StorageSync/Common/StorageSyncClientWrapper.cs

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.Azure.Commands.StorageSync.Interfaces;
1818
using Microsoft.Azure.Commands.StorageSync.Properties;
19-
using Microsoft.Azure.Graph.RBAC.Version1_6_20190326.ActiveDirectory;
20-
using Microsoft.Azure.Graph.RBAC.Version1_6_20190326.Models;
19+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0;
20+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications;
21+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
22+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Users.Models;
2123
using Microsoft.Azure.Management.Authorization.Version2015_07_01;
2224
using Microsoft.Azure.Management.Authorization.Version2015_07_01.Models;
2325
using Microsoft.Azure.Management.Internal.Resources;
@@ -55,11 +57,6 @@ public class StorageSyncClientWrapper : IStorageSyncClientWrapper
5557

5658
private static Guid AzureUSGovernmentKailaniAppId = new Guid("ce88d19b-f69a-4c2e-ac8a-d1aa9db611e8");
5759

58-
/// <summary>
59-
/// The azure us product test kailani application identifier
60-
/// </summary>
61-
private static Guid AzureUSProdTestKailaniAppId = new Guid("1fcdfafe-959b-4b32-afff-84f850974e84");
62-
6360
/// <summary>
6461
/// The built in role definition identifier
6562
/// </summary>
@@ -90,10 +87,10 @@ public class StorageSyncClientWrapper : IStorageSyncClientWrapper
9087
public IResourceManagementClient ResourceManagementClient { get; set; }
9188

9289
/// <summary>
93-
/// Gets or sets the active directory client.
90+
/// Gets or sets the Microsoft Graph Client.
9491
/// </summary>
95-
/// <value>The active directory client.</value>
96-
public ActiveDirectoryClient ActiveDirectoryClient { get; set; }
92+
/// <value>The Microsoft Graph client.</value>
93+
public MicrosoftGraphClient MicrosoftGraphClient { get; set; }
9794

9895
/// <summary>
9996
/// Gets or sets the verbose logger.
@@ -112,12 +109,12 @@ public class StorageSyncClientWrapper : IStorageSyncClientWrapper
112109
/// </summary>
113110
/// <param name="context">The context.</param>
114111
/// <param name="activeDirectoryClient">The active directory client.</param>
115-
public StorageSyncClientWrapper(IAzureContext context, ActiveDirectoryClient activeDirectoryClient)
112+
public StorageSyncClientWrapper(IAzureContext context, MicrosoftGraphClient microsoftGraphClient)
116113
: this(AzureSession.Instance.ClientFactory.CreateArmClient<StorageSyncManagementClient>(context, AzureEnvironment.Endpoint.ResourceManager),
117114
AzureSession.Instance.ClientFactory.CreateArmClient<AuthorizationManagementClient>(context, AzureEnvironment.Endpoint.ResourceManager),
118115
AzureSession.Instance.ClientFactory.CreateArmClient<ResourceManagementClient>(context, AzureEnvironment.Endpoint.ResourceManager))
119116
{
120-
ActiveDirectoryClient = activeDirectoryClient;
117+
MicrosoftGraphClient = microsoftGraphClient;
121118

122119
if (AzureSession.Instance.TryGetComponent(StorageSyncConstants.StorageSyncResourceManager, out IStorageSyncResourceManager storageSyncResourceManager))
123120
{
@@ -181,21 +178,13 @@ public Guid CurrentApplicationId
181178
{
182179
get
183180
{
184-
if (StorageSyncConstants.ResourceProvider.EndsWith("Int", StringComparison.InvariantCultureIgnoreCase) ||
185-
StorageSyncConstants.ResourceProvider.EndsWith("Dev", StringComparison.InvariantCultureIgnoreCase))
186-
{
187-
return AzureUSProdTestKailaniAppId;
188-
}
189-
else
190-
{
191181
switch (AzureRmProfileProvider.Instance?.Profile?.DefaultContext?.Environment?.Name)
192182
{
193183
case EnvironmentName.AzureUSGovernment:
194184
return AzureUSGovernmentKailaniAppId;
195185
default:
196186
return AzureCloudKailaniAppId;
197187
}
198-
}
199188
}
200189
}
201190

@@ -231,37 +220,17 @@ public string AfsAgentVersion
231220
/// Ensures the service principal.
232221
/// </summary>
233222
/// <returns>PSADServicePrincipal.</returns>
234-
public PSADServicePrincipal EnsureServicePrincipal()
223+
public MicrosoftGraphServicePrincipal GetServicePrincipalOrNull()
235224
{
236225
string applicationId = CurrentApplicationId.ToString();
237-
string appObjectId = ActiveDirectoryClient.GetServicePrincipalsIdByAppId(CurrentApplicationId);
238-
PSADServicePrincipal servicePrincipal = ActiveDirectoryClient.GetServicePrincipalByObjectId(appObjectId);
226+
// TODO: Remove this call once Az Powershell supports MSGraphClient in Test framework.
227+
MicrosoftGraphServicePrincipal servicePrincipal = this.StorageSyncResourceManager.GetServicePrincipalOrNull();
239228

240229
if (servicePrincipal == null)
241230
{
242-
VerboseLogger.Invoke(StorageSyncResources.CreateServicePrincipalMessage);
243-
// Create an application and get the applicationId
244-
var passwordCredential = new PSADPasswordCredential()
245-
{
246-
StartDate = DateTime.Now,
247-
EndDate = DateTime.Now.AddYears(1),
248-
KeyId = Guid.NewGuid(),
249-
Password = SecureStringExtensions.ConvertToString(Guid.NewGuid().ToString().ConvertToSecureString())
250-
};
251-
252-
var createParameters = new CreatePSServicePrincipalParameters
253-
{
254-
ApplicationId = CurrentApplicationId,
255-
AccountEnabled = bool.TrueString,
256-
PasswordCredentials = new PSADPasswordCredential[]
257-
{
258-
passwordCredential
259-
}
260-
};
261-
262-
servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters);
231+
var oDataQuery = new ODataQuery<MicrosoftGraphServicePrincipal>(sp => sp.AppId == applicationId);
232+
servicePrincipal = MicrosoftGraphClient.FilterServicePrincipals(oDataQuery).FirstOrDefault();
263233
}
264-
265234
return servicePrincipal;
266235
}
267236

@@ -273,7 +242,7 @@ public PSADServicePrincipal EnsureServicePrincipal()
273242
/// <param name="storageAccountSubscriptionId">The storage account subscription identifier.</param>
274243
/// <param name="storageAccountResourceId">The storage account resource identifier.</param>
275244
/// <returns>RoleAssignment.</returns>
276-
public RoleAssignment EnsureRoleAssignment(PSADServicePrincipal serverPrincipal, string storageAccountSubscriptionId, string storageAccountResourceId)
245+
public RoleAssignment EnsureRoleAssignment(MicrosoftGraphServicePrincipal serverPrincipal, string storageAccountSubscriptionId, string storageAccountResourceId)
277246
{
278247
string currentSubscriptionId = AuthorizationManagementClient.SubscriptionId;
279248
bool hasMismatchSubscription = currentSubscriptionId != storageAccountSubscriptionId;

src/StorageSync/StorageSync/Common/StorageSyncResourceManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Commands.StorageSync.Interop.Clients;
1616
using Commands.StorageSync.Interop.DataObjects;
1717
using Commands.StorageSync.Interop.Interfaces;
18+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
1819
using Microsoft.Azure.Commands.StorageSync.Interfaces;
1920
using Microsoft.Win32;
2021
using System;
@@ -101,5 +102,11 @@ public void Wait()
101102
/// </summary>
102103
/// <returns>System.String.</returns>
103104
public string GetTenantId() => null;
105+
106+
/// <summary>
107+
/// Get Service Principal Or Null
108+
/// </summary>
109+
/// <returns>MicrosoftGraphServicePrincipal</returns>
110+
public MicrosoftGraphServicePrincipal GetServicePrincipalOrNull() => null;
104111
}
105112
}

src/StorageSync/StorageSync/Interfaces/IStorageSyncClientWrapper.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
16-
using Microsoft.Azure.Graph.RBAC.Version1_6_20190326.ActiveDirectory;
16+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0;
17+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications;
18+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
19+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Users.Models;
1720
using Microsoft.Azure.Management.Authorization.Version2015_07_01;
1821
using Microsoft.Azure.Management.Authorization.Version2015_07_01.Models;
1922
using Microsoft.Azure.Management.Internal.Resources;
@@ -30,10 +33,10 @@ public interface IStorageSyncClientWrapper
3033
{
3134

3235
/// <summary>
33-
/// Gets or sets the active directory client.
36+
/// Gets or sets the Microsoft Graph Client.
3437
/// </summary>
35-
/// <value>The active directory client.</value>
36-
ActiveDirectoryClient ActiveDirectoryClient { get; set; }
38+
/// <value>The Microsoft Graph client.</value>
39+
MicrosoftGraphClient MicrosoftGraphClient { get; set; }
3740

3841
/// <summary>
3942
/// Gets or sets the storage sync management client.
@@ -75,7 +78,7 @@ public interface IStorageSyncClientWrapper
7578
/// Ensures the service principal.
7679
/// </summary>
7780
/// <returns>PSADServicePrincipal.</returns>
78-
PSADServicePrincipal EnsureServicePrincipal();
81+
MicrosoftGraphServicePrincipal GetServicePrincipalOrNull();
7982

8083
/// <summary>
8184
/// Ensures the role assignment.
@@ -84,7 +87,7 @@ public interface IStorageSyncClientWrapper
8487
/// <param name="storageAccountSubscriptionId">The storage account subscription identifier.</param>
8588
/// <param name="storageAccountResourceId">The storage account resource identifier.</param>
8689
/// <returns>RoleAssignment.</returns>
87-
RoleAssignment EnsureRoleAssignment(PSADServicePrincipal serverPrincipal, string storageAccountSubscriptionId, string storageAccountResourceId);
90+
RoleAssignment EnsureRoleAssignment(MicrosoftGraphServicePrincipal serverPrincipal, string storageAccountSubscriptionId, string storageAccountResourceId);
8891

8992
/// <summary>
9093
/// This function will invoke the registration and continue operation with a success function call.

src/StorageSync/StorageSync/Interfaces/IStorageSyncResourceManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Commands.StorageSync.Interop.DataObjects;
1616
using Commands.StorageSync.Interop.Interfaces;
17+
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
1718
using System;
1819

1920
namespace Microsoft.Azure.Commands.StorageSync.Interfaces
@@ -23,6 +24,12 @@ namespace Microsoft.Azure.Commands.StorageSync.Interfaces
2324
/// </summary>
2425
public interface IStorageSyncResourceManager
2526
{
27+
/// <summary>
28+
/// Get Service Principal Or Null
29+
/// </summary>
30+
/// <returns>MicrosoftGraphServicePrincipal</returns>
31+
MicrosoftGraphServicePrincipal GetServicePrincipalOrNull();
32+
2633
/// <summary>
2734
/// Creates the ecs management.
2835
/// </summary>

0 commit comments

Comments
 (0)