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
MaxScore
andScore
variables 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) ) )
scoreInPercentage
is 0 to avoid division by zero. If it is, it setsMaxScore
to 1. Otherwise, it calculatesMaxScore
by dividingScore
by the percentage converted to a decimal. - Handling Zero Scores: Sometimes
Score
andscoreInPercentage
are 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: ifScore
is 0, retrieveMaxScore
using the API; otherwise, use the calculated value. - Summing Scores: Sum all
Score
values andMaxScore
values for each control in the category. Divide the totalScore
by the totalMaxScore
to 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