📖 Scenario: You are working in a cloud team that manages many Azure resources. To keep things organized and easy to find, your team follows strict naming rules for resources.For example, resource names must include the environment, resource type, and a unique identifier, all separated by hyphens.
🎯 Goal: Create a list of Azure resource names following the naming convention: env-type-uniqueid. Then filter the list to only include production environment resources.
📋 What You'll Learn
Create a list called resource_names with exact resource names
Create a variable called environment set to 'prod'
Use a list comprehension to create a new list prod_resources with only names starting with the environment value
Add a final line to print the prod_resources list
💡 Why This Matters
🌍 Real World
In real cloud projects, consistent resource naming helps teams find and manage resources easily, especially in large environments.
💼 Career
Understanding and applying naming conventions is a key skill for cloud engineers and architects to maintain organized and scalable cloud infrastructure.
Progress0 / 4 steps
1
Create the initial list of resource names
Create a list called resource_names with these exact strings: 'dev-vm-001', 'prod-db-002', 'test-app-003', 'prod-vm-004', 'dev-db-005'
Azure
Hint
Use square brackets to create a list and include all resource names as strings separated by commas.
2
Set the environment filter variable
Create a variable called environment and set it to the string 'prod'
Azure
Hint
Use a simple assignment to create the variable environment.
3
Filter the list for production resources
Use a list comprehension to create a new list called prod_resources that includes only the resource names from resource_names that start with the value in environment followed by a hyphen. Use for name in resource_names and name.startswith(environment + '-') in the comprehension.
Azure
Hint
Use a list comprehension with name.startswith(environment + '-') to filter the list.
4
Print the filtered production resources
Add a line to print the prod_resources list.
Azure
Hint
Use the print function to display the list.
Practice
(1/5)
1. Which of the following is a best practice for naming Azure resources?
easy
A. Include environment, resource type, and location in the name
B. Use spaces and special characters freely
C. Keep names very short without any identifiers
D. Use only uppercase letters for all resource names
Solution
Step 1: Understand Azure naming best practices
Azure recommends including environment (like dev or prod), resource type, and location to organize resources clearly.
Step 2: Evaluate each option
Including environment, resource type, and location in the name follows best practices. Using spaces and special characters freely, keeping names very short without any identifiers, and using only uppercase letters for all resource names do not follow best practices or reduce clarity.
Final Answer:
Include environment, resource type, and location in the name -> Option A
Quick Check:
Best practice = Include environment, type, location [OK]
Hint: Names should describe environment, type, and location [OK]
Common Mistakes:
Using spaces or special characters
Ignoring environment or location in names
Using inconsistent casing
2. Which of these Azure resource names is valid according to Azure naming rules?
easy
A. my-resource-01
B. my resource 01
C. myResource_01
D. myResource@01
Solution
Step 1: Recall Azure naming rules
Azure allows letters, numbers, and hyphens (-) but not spaces or special characters like underscores (_) or @.
Step 2: Check each option
my-resource-01 uses only letters, numbers, and hyphens, so it's valid. myResource_01 contains an underscore, my resource 01 contains spaces, and myResource@01 contains @, all invalid characters.
Final Answer:
my-resource-01 -> Option A
Quick Check:
Valid characters = letters, numbers, hyphens [OK]
Hint: Use only letters, numbers, and hyphens in names [OK]
Common Mistakes:
Using underscores or spaces
Including special characters like @ or #
Starting or ending names with hyphens
3. Given the resource name prod-webapp-eastus-001, what does this name most likely represent?
medium
A. A development database in West Europe region
B. A production web application in East US region with unique ID 001
C. A test storage account in Central US region
D. An invalid resource name with no meaning
Solution
Step 1: Break down the resource name parts
"prod" means production environment, "webapp" is resource type, "eastus" is location, "001" is unique ID.
Step 2: Match parts to options
A production web application in East US region with unique ID 001 matches all parts correctly. Other options mention wrong environment, type, or location.
Final Answer:
A production web application in East US region with unique ID 001 -> Option B
Quick Check:
prod + webapp + eastus + 001 = A production web application in East US region with unique ID 001 [OK]
Hint: Split name by hyphens to identify parts [OK]
Common Mistakes:
Confusing environment or location codes
Ignoring unique ID meaning
Assuming invalid names
4. You try to create an Azure storage account named storage_account_01 but get an error. What is the most likely cause?
medium
A. Storage account names cannot include numbers
B. Storage account names must be uppercase
C. Storage account names cannot contain underscores
D. Storage account names must be longer than 30 characters
Solution
Step 1: Recall storage account naming rules
Storage account names must be lowercase letters and numbers only, no underscores allowed.
Step 2: Analyze the error cause
The name contains an underscore, which is invalid. Other options are incorrect rules.
Final Answer:
Storage account names cannot contain underscores -> Option C
Quick Check:
Underscores not allowed in storage account names [OK]
Hint: Storage names allow only lowercase letters and numbers [OK]
Common Mistakes:
Using uppercase letters
Including underscores or special characters
Misunderstanding length limits
5. You need to create a naming convention for Azure resources that includes environment, resource type, location, and a unique ID. Which of the following names follows best practices and Azure rules?
hard
A. Dev_VM_WestUS_01
B. dev-vm-westus-01!
C. devvmwestus01
D. dev-vm-westus-01
Solution
Step 1: Check naming convention components
The name should include environment (dev), resource type (vm), location (westus), and unique ID (01) separated by hyphens.
Step 2: Validate Azure naming rules
dev-vm-westus-01 uses lowercase letters, hyphens, and no invalid characters. Dev_VM_WestUS_01 uses uppercase and underscores, devvmwestus01 lacks separators, dev-vm-westus-01! has an exclamation mark.
Final Answer:
dev-vm-westus-01 -> Option D
Quick Check:
Lowercase + hyphens + all parts = dev-vm-westus-01 [OK]
Hint: Use lowercase and hyphens to separate parts [OK]
Common Mistakes:
Using uppercase letters or underscores
Missing separators between parts
Including special characters
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.