Bird
Raised Fist0
Azurecloud~30 mins

Security recommendations and score in Azure - Mini Project: Build & Apply

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Security Recommendations and Score in Azure
📖 Scenario: You are managing an Azure subscription and want to improve its security. Azure Security Center provides recommendations and a security score to help you understand and fix security issues.In this project, you will create a simple script to retrieve security recommendations and the current security score for your Azure subscription.
🎯 Goal: Build a script that connects to Azure Security Center, fetches the list of security recommendations, and retrieves the current security score for your subscription.
📋 What You'll Learn
Create a variable to hold the Azure subscription ID
Create a variable to hold the resource provider namespace for security
Write a function to fetch security recommendations from Azure Security Center
Write a function to fetch the current security score
Combine the functions to output the recommendations and score
💡 Why This Matters
🌍 Real World
Azure Security Center helps cloud administrators monitor and improve the security posture of their Azure subscriptions by providing actionable recommendations and a security score.
💼 Career
Understanding how to retrieve and use security recommendations and scores is essential for cloud security engineers and administrators to maintain secure cloud environments.
Progress0 / 4 steps
1
Set up Azure subscription ID and resource provider
Create a variable called subscription_id and set it to the string "12345678-1234-1234-1234-123456789abc". Then create a variable called security_provider and set it to the string "Microsoft.Security".
Azure
Hint

Use simple string assignment to create the variables.

2
Create a function to fetch security recommendations
Define a function called get_security_recommendations that takes subscription_id as a parameter. Inside the function, create a variable called recommendations_endpoint and set it to the string f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Security/assessments?api-version=2020-01-01".
Azure
Hint

Use an f-string to build the URL with the subscription ID.

3
Create a function to fetch the security score
Define a function called get_security_score that takes subscription_id as a parameter. Inside the function, create a variable called score_endpoint and set it to the string f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Security/secureScores?api-version=2020-01-01".
Azure
Hint

Use an f-string to build the URL with the subscription ID for the security score.

4
Combine functions to get recommendations and score URLs
Create two variables: recommendations_url and score_url. Assign recommendations_url the result of calling get_security_recommendations(subscription_id). Assign score_url the result of calling get_security_score(subscription_id).
Azure
Hint

Call each function with subscription_id and assign the results to the variables.

Practice

(1/5)
1. What does the Azure security score represent?
easy
A. A number showing how well your cloud resources are protected
B. The total cost of your Azure services
C. The number of users in your Azure subscription
D. The amount of storage used in your Azure account

Solution

  1. Step 1: Understand the purpose of security score

    The security score is designed to give a simple measure of how secure your cloud environment is.
  2. Step 2: Identify what the score reflects

    It reflects how many security recommendations you have fixed and how protected your resources are.
  3. Final Answer:

    A number showing how well your cloud resources are protected -> Option A
  4. Quick Check:

    Security score = protection level [OK]
Hint: Security score measures protection level, not cost or users [OK]
Common Mistakes:
  • Confusing security score with cost or usage metrics
  • Thinking it counts users or storage instead of security
  • Assuming it is a percentage instead of a score
2. Which Azure CLI command shows your current security recommendations and score?
easy
A. az vm list
B. az network vnet list
C. az storage account show
D. az security assessment list

Solution

  1. Step 1: Identify the command related to security

    The command to get security recommendations and score is under the 'security' group in Azure CLI.
  2. Step 2: Match the command to the correct syntax

    'az security assessment list' lists security assessments and recommendations.
  3. Final Answer:

    az security assessment list -> Option D
  4. Quick Check:

    Security info = az security assessment list [OK]
Hint: Security commands start with az security [OK]
Common Mistakes:
  • Choosing commands unrelated to security
  • Confusing VM or storage commands with security commands
  • Using commands that list resources but not security info
3. You run az security assessment list and see 5 recommendations. After fixing 3, what happens to your security score?
medium
A. It resets to zero automatically
B. It increases because you fixed some recommendations
C. It stays the same because score does not change
D. It decreases because you had recommendations

Solution

  1. Step 1: Understand how fixing recommendations affects score

    Fixing security recommendations improves your protection, so the score should increase.
  2. Step 2: Eliminate incorrect options

    The score does not decrease or reset to zero when fixing issues; it reflects improvement.
  3. Final Answer:

    It increases because you fixed some recommendations -> Option B
  4. Quick Check:

    Fixing issues = score up [OK]
Hint: Fixing recommendations raises your security score [OK]
Common Mistakes:
  • Thinking score decreases when fixing issues
  • Believing score stays constant regardless of fixes
  • Assuming score resets after changes
4. You tried to run az security assessment list but got an error saying 'command not found'. What is the likely cause?
medium
A. Azure CLI is not installed or not updated
B. You typed the command correctly but your internet is off
C. Your subscription has no virtual machines
D. You need to run the command inside a virtual machine

Solution

  1. Step 1: Analyze the error message

    'Command not found' usually means the CLI tool or extension is missing or outdated.
  2. Step 2: Check other options

    Internet off would cause different errors; subscription content or VM location does not cause 'command not found'.
  3. Final Answer:

    Azure CLI is not installed or not updated -> Option A
  4. Quick Check:

    Command not found = CLI missing or outdated [OK]
Hint: Command not found means CLI missing or outdated [OK]
Common Mistakes:
  • Assuming internet off causes 'command not found'
  • Thinking subscription content affects command availability
  • Trying to run commands only inside VMs
5. Your Azure security score is low due to many open ports on virtual machines. What is the best way to improve your score?
hard
A. Add more storage accounts
B. Increase the size of your virtual machines
C. Close unnecessary ports using network security groups
D. Create more virtual networks

Solution

  1. Step 1: Identify the security risk

    Open ports increase attack surface; closing unnecessary ports reduces risk.
  2. Step 2: Choose the best action to reduce risk

    Network security groups control ports; closing ports improves security score.
  3. Step 3: Eliminate unrelated options

    Increasing VM size, adding storage, or creating networks do not reduce open ports or improve security score.
  4. Final Answer:

    Close unnecessary ports using network security groups -> Option C
  5. Quick Check:

    Close ports = better security score [OK]
Hint: Close open ports with security groups to boost score [OK]
Common Mistakes:
  • Thinking bigger VMs improve security score
  • Adding storage or networks unrelated to port security
  • Ignoring network security group rules