0
0
Azurecloud~10 mins

Security recommendations and score in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to retrieve the security score from Azure Security Center.

Azure
security_score = client.security_scores.get('[1]')
Drag options to blanks, or click blank then click option'
Adefault
Bcurrent
Clatest
Dsummary
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' which does not specify the latest score.
Using 'summary' which is not a valid parameter here.
2fill in blank
medium

Complete the code to list all security recommendations for a subscription.

Azure
recommendations = client.security_recommendations.list('[1]')
Drag options to blanks, or click blank then click option'
AsubscriptionId
BresourceGroupName
CmanagementGroupId
DtenantId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'resourceGroupName' which scopes too narrowly.
Using 'tenantId' which is broader than subscription.
3fill in blank
hard

Fix the error in the code to correctly fetch security recommendations with filters.

Azure
filtered_recommendations = client.security_recommendations.list(filter='[1]')
Drag options to blanks, or click blank then click option'
Aseverity eq 'High' and state eq 'Active'
Bseverity == 'High' and state == 'Active'
Cseverity = 'High' and state = 'Active'
Dseverity equals 'High' and state equals 'Active'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which is invalid in OData filters.
Using '=' which is assignment, not comparison.
4fill in blank
hard

Fill both blanks to create a dictionary of recommendation names and their states.

Azure
rec_states = {rec.[1]: rec.[2] for rec in recommendations}
Drag options to blanks, or click blank then click option'
Aname
Bstate
Cid
Dseverity
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' as key which is less readable.
Using 'severity' as value which is not the state.
5fill in blank
hard

Fill all three blanks to filter and count active high severity recommendations.

Azure
active_high = [rec for rec in recommendations if rec.[1] == '[2]' and rec.[3] == 'Active']
count = len(active_high)
Drag options to blanks, or click blank then click option'
Aseverity
BHigh
Cstate
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'state' for filtering.
Using wrong severity value.