Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{HDInsight}Hdi migrate Microsoft.Azure.Graph to MicrosoftGraph #17219

Merged
merged 5 commits into from
Mar 1, 2022

Conversation

aim-for-better
Copy link
Member

@aim-for-better aim-for-better commented Feb 22, 2022

Description

Migrate Microsoft.Azure.Graph to MicrosoftGraph

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:
    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

Copy link
Member

@isra-fel isra-fel left a comment

Choose a reason for hiding this comment

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

Please put the following content in the help document of NewAzureHDInsightClusterCommand:

The cmdlet may call below Microsoft Graph API according to input parameters:

GET /servicePrincipals/{id}

@@ -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

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

{
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

@aim-for-better
Copy link
Member Author

Hi @isra-fel Thanks for your review, I have updated the PR.

@aim-for-better
Copy link
Member Author

Please put the following content in the help document of NewAzureHDInsightClusterCommand:

The cmdlet may call below Microsoft Graph API according to input parameters:

GET /servicePrincipals/{id}

Added

@@ -100,6 +100,10 @@ New-AzHDInsightCluster [-Location] <String> [-ResourceGroupName] <String> [-Clus
## DESCRIPTION
The New-AzHDInsightCluster creates an Azure HDInsight cluster by using the specified parameters or by using a configuration object that is created by using the New-AzHDInsightClusterConfig cmdlet.

The cmdlet may call below Microsoft Graph API according to input parameters:

- GET /servicePrincipals/{id}
Copy link
Member Author

Choose a reason for hiding this comment

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

Added in the help doc

@isra-fel
Copy link
Member

isra-fel commented Mar 1, 2022

/azp run azure-powershell - security-tools

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@BethanyZhou BethanyZhou merged commit fbc35fd into Azure:main Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants