Azure Administrator AZ-104 · Deploy and Manage Azure Compute Resources · medium
An administrator wants to deploy 4 Azure Storage accounts (stlogs0, stlogs1, stlogs2, stlogs3) across a resource group using a single Bicep resource block without duplicating the resource declaration four times. Which Bicep syntax construct iterates over a range to provision multiple instances of a resource?
Published · Last updated · checked before publication — how we verify questions
Options
Answer: A. A [for i in range(0, 4): { ... }] loop expression on the resource
Bicep lets you deploy many copies of one resource by adding a for expression to the resource declaration. The syntax is a bracketed loop such as [for i in range(0, 4): { ... }], where range(0, 4) produces the integers 0, 1, 2 and 3, and the loop body defines the properties of each instance. Using the loop index in the name, for example 'stlogs${i}', yields stlogs0 through stlogs3 from a single declaration. The same loop construct works on modules, variables, properties and outputs, and you can also loop over an array of values or objects. A common trap is forgetting that range takes a start index and a count, not an end value, so range(0, 4) gives four items. Another trap is confusing resource iteration with deployment behavior settings, which control what happens to existing resources and do not create new instances.
Why the other options are wrong
- B. Four nested CanNotDelete lock resources inside the metadata block — A CanNotDelete lock is a management lock that protects a resource from deletion, and it is a separate resource type that applies to a scope. It does not iterate and does not create storage accounts, and a metadata block only holds descriptive information about the file.
- C. Setting the resource group deployment mode parameter to Complete — Complete deployment mode makes Azure Resource Manager delete resources in the resource group that are not in the template, whereas Incremental leaves them alone. It governs cleanup of undeclared resources and has no effect on how many instances a single declaration creates.
- D. Adding a dependsOn array pointing the storage account to itself — The dependsOn property orders deployment by making one resource wait for another. A resource that depends on itself creates a circular dependency, which fails validation, and in any case dependsOn never creates multiple instances.
More Deploy and Manage Azure Compute Resources questions
- You deploy 12 identical Azure Virtual Machines into a single Availability Set configured with 3 Fault Domains (FDs)…
- A security policy prohibits assigning Public IP addresses to any Azure Virtual Machine and forbids opening inbound…
- A web team uses Azure App Service (Standard S1 plan) with a production slot and a staging deployment slot. The staging…
- A resource group named RG-App currently contains three resources: VM1, VNet1, and Storage1. An administrator runs az…
- A platform engineering team has perfected a golden ARM / Bicep template for deploying compliant virtual networks and…
All Deploy and Manage Azure Compute Resources questions and the topic overview →
Microsoft and Azure are trademarks of Microsoft Corporation. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Microsoft Corporation.