Hello @Bader, Andreas
Thank you for posting your query on Microsoft Q&A.
Using Logic Apps and the Microsoft Graph API, we will be able to calculate security scores for various categories like Apps and Identity. Here's a concise explanation of the process:
- API Used: https://graph.microsoft.com/v1.0/security/secureScores to get all controls, their scores, and scores in percentage.
- Process: Use a "For Each" loop to iterate through each category. Inside the loop, filter the array to process each category individually (e.g., Apps, Identity, etc.). Initialize
MaxScoreandScorevariables to 0.- Score Calculation:
Use a compose action with the following equation to calculateMaxScore:
if(
This expression checks ifequals(mul(float(items('For_each_6')?['scoreInPercentage']), 0.01), 0), 1, div( items('For_each_6')?['score'], mul(float(items('For_each_6')?['scoreInPercentage']), 0.01) ) )scoreInPercentageis 0 to avoid division by zero. If it is, it setsMaxScoreto 1. Otherwise, it calculatesMaxScoreby dividingScoreby the percentage converted to a decimal. - Handling Zero Scores: Sometimes
ScoreandscoreInPercentageare 0 even if there is aMaxScore. To handle this, use an HTTP request before the second loop with this API: [Microsoft Graph API for Control Profiles] to retrieveMaxScore. Create a condition: ifScoreis 0, retrieveMaxScoreusing the API; otherwise, use the calculated value. - Summing Scores: Sum all
Scorevalues andMaxScorevalues for each control in the category. Divide the totalScoreby the totalMaxScoreto get the percentage for that control category.
Refer to below documents:
List Secure Scores: https://learn.microsoft.com/en-us/graph/api/security-list-securescores?view=graph-rest-1.0&tabs=http
https://learn.microsoft.com/en-us/graph/api/resources/securescore?view=graph-rest-1.0
https://learn.microsoft.com/en-us/graph/api/resources/securescorecontrolprofile?view=graph-rest-1.0
Refer similar threads: https://learn.microsoft.com/en-us/answers/questions/494552/graph-microsoft-securescore-data-what-values-are-a
I hope this clarifies things. Please contact us if you have any additional questions.
If this answers your query, do click Accept Answer and Yes for "Was this answer helpful". And, if you have any further query do let us know.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Sakshi Devkante