Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' which does not specify the latest score.
Using 'summary' which is not a valid parameter here.
✗ Incorrect
The latest parameter retrieves the most recent security score.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'resourceGroupName' which scopes too narrowly.
Using 'tenantId' which is broader than subscription.
✗ Incorrect
The subscriptionId is required to list recommendations for that subscription.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which is invalid in OData filters.
Using '=' which is assignment, not comparison.
✗ Incorrect
Azure uses OData filter syntax where eq means equals.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' as key which is less readable.
Using 'severity' as value which is not the state.
✗ Incorrect
Use name as the key and state as the value to map recommendations to their states.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'state' for filtering.
Using wrong severity value.
✗ Incorrect
Filter by severity equal to High and state equal to 'Active' to get the count.