Challenge - 5 Problems
Azure Scripting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
Azure CLI Loop Variable Behavior
Consider this Azure CLI script snippet that loops to create resource groups with variable names. What will be the name of the last resource group created?
Azure
for i in {1..3}; do az group create --name myResourceGroup$i --location eastus; done
Attempts:
2 left
💡 Hint
The loop runs from 1 to 3 inclusive, appending the loop variable to the name.
✗ Incorrect
The loop variable i takes values 1, 2, and 3. The last iteration creates 'myResourceGroup3'.
❓ Configuration
intermediate2:00remaining
Azure ARM Template Loop Variable Usage
In an Azure ARM template, you want to create 3 storage accounts with names 'storageacct1', 'storageacct2', and 'storageacct3' using a loop. Which of the following 'copy' loop configurations correctly sets the storage account names?
Attempts:
2 left
💡 Hint
copyIndex() starts at 0, so add 1 to start names at 1.
✗ Incorrect
copyIndex() returns 0,1,2. Adding 1 produces 1,2,3 for the names as required.
❓ Architecture
advanced2:00remaining
Automating VM Creation with Azure CLI Loops
You want to create 5 Azure virtual machines named vm1 to vm5 in a loop using Azure CLI. Which script snippet correctly uses a loop and variable to create these VMs with the name pattern?
Attempts:
2 left
💡 Hint
Use brace expansion {1..5} for a simple loop from 1 to 5.
✗ Incorrect
Brace expansion {1..5} loops from 1 to 5 inclusively, creating vm1 to vm5 as desired.
❓ security
advanced2:00remaining
Looping Over Secrets in Azure Key Vault
You have a script that loops over a list of secret names to retrieve their values from Azure Key Vault. Which approach correctly uses variables and loops to fetch and print each secret's value securely?
Attempts:
2 left
💡 Hint
Use -o tsv to get raw secret value without extra formatting.
✗ Incorrect
Using '-o tsv' outputs the secret value as plain text, suitable for secure handling in scripts.
✅ Best Practice
expert3:00remaining
Efficient Variable Use in Azure CLI Loops for Resource Tagging
You want to tag multiple Azure resources in a loop with a variable tag value that changes each iteration. Which script snippet correctly updates the tag value variable inside the loop and applies it to each resource?
Attempts:
2 left
💡 Hint
Assign the variable inside the loop with quotes to handle the string correctly.
✗ Incorrect
Assigning tagValue="env$i" inside the loop ensures the variable updates each iteration and is used correctly in the tag command.