Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
using System.IO;
using System.Linq;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Graph.RBAC.Version1_6;
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0;

namespace Commands.HDInsight.Test.ScenarioTests
Expand Down
1 change: 1 addition & 0 deletions src/HDInsight/HDInsight/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
This release migrates Microsoft.Azure.Graph SDK to MicrsoftGraph SDK, there is not customer impact.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration might have impact on customers because the permission required to call AAD graph and MS graph APIs are different.

Suggested change
This release migrates Microsoft.Azure.Graph SDK to MicrsoftGraph SDK, there is not customer impact.
This release migrates Microsoft.Azure.Graph SDK to MicrsoftGraph SDK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


## Version 5.0.0
* Added two parameters `-Zone` and `-PrivateLinkConfiguration` to cmdlet `New-AzHDInsightCluster`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0;
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models;
using Microsoft.Azure.Commands.HDInsight.Commands;
using Microsoft.Azure.Commands.HDInsight.Models;
using Microsoft.Azure.Commands.HDInsight.Models.Management;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Graph.RBAC.Version1_6;
using Microsoft.Azure.Management.HDInsight.Models;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
Expand Down Expand Up @@ -664,20 +665,20 @@ private Guid GetApplicationId(Guid applicationId)
return applicationId;
}

GraphRbacManagementClient graphClient = AzureSession.Instance.ClientFactory.CreateArmClient<GraphRbacManagementClient>(
MicrosoftGraphClient graphClient = AzureSession.Instance.ClientFactory.CreateArmClient<MicrosoftGraphClient>(
DefaultProfile.DefaultContext, AzureEnvironment.Endpoint.Graph);

graphClient.TenantID = DefaultProfile.DefaultContext.Tenant.Id.ToString();

Microsoft.Azure.Graph.RBAC.Version1_6.Models.ServicePrincipal sp = null;
MicrosoftGraphServicePrincipal sp = null;
try
{
sp = graphClient.ServicePrincipals.Get(ObjectId.ToString());
sp = graphClient.ServicePrincipals.GetServicePrincipalWithHttpMessagesAsync(ObjectId.ToString()).Result.Body;//graphClient.ServicePrincipals.Get(ObjectId.ToString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use this extension method to simplify code: https://github.com/Azure/azure-powershell-common/blob/main/src/Graph.Rbac/MicrosoftGraph/Version1_0/Applications/ServicePrincipalsOperationsExtensions.cs#L210

Suggested change
sp = graphClient.ServicePrincipals.GetServicePrincipalWithHttpMessagesAsync(ObjectId.ToString()).Result.Body;//graphClient.ServicePrincipals.Get(ObjectId.ToString());
sp = graphClient.ServicePrincipals.GetServicePrincipal(ObjectId.ToString());

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

}
catch (Microsoft.Azure.Graph.RBAC.Version1_6.Models.GraphErrorException e)
catch (Exception e)
{
string errorMessage = e.Message + ". Please specify Application Id explicitly by providing ApplicationId parameter and retry.";
throw new Microsoft.Azure.Graph.RBAC.Version1_6.Models.GraphErrorException(errorMessage);
throw new Exception(errorMessage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use AzPSArgumentException so we can get detailed telemetry data.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

}

var spApplicationId = Guid.Empty;
Expand Down