AZ-104 · Question #178
Hotspot Question You have an Azure subscription. You need to use an Azure Resource Manager (ARM) template to create a virtual machine that will have multiple data disks. How should you complete the…
The correct answer is Property for data disks definition: "copy":[; Value for lun property: "[copy". To create multiple data disks for a virtual machine using an ARM template, use the 'copy' loop construct for the data disks array and assign a unique Logical Unit Number (LUN) to each disk using the 'copyIndex' function.
Question
Exhibit
Answer Area
- Property for data disks definition"copy":["copy":["copyIndex":["dependsOn":[
- Value for lun property"[copy""[copy""[copyIndex""[dependsOn"
Explanation
To create multiple data disks for a virtual machine using an ARM template, use the 'copy' loop construct for the data disks array and assign a unique Logical Unit Number (LUN) to each disk using the 'copyIndex' function.
Approach. 1. First Hotspot (Top Dropdown): The question requires creating multiple data disks based on the numberOfDataDisks parameter. The JSON structure following the first dropdown ({ "name": "dataDisks", "count": "parameters('numberOfDataDisks')", "input": {...} }) is the standard syntax for defining a 'copy' loop in an ARM template to create multiple instances of a resource or property. Therefore, the appropriate selection for this dropdown is copy. This tells the ARM template engine to create an array of data disks by iterating numberOfDataDisks times, using the definition provided in the input block.
2. Second Hotspot (Bottom Dropdown): The lun (Logical Unit Number) property for each data disk must be unique within a virtual machine. When creating multiple data disks using a 'copy' loop, the copyIndex() function is used to get the current iteration number, which starts at 0 by default. This provides a unique, sequential number for each disk's LUN (0, 1, 2, ...). Therefore, the appropriate selection for this dropdown is copyIndex to assign the loop index as the LUN.
Common mistakes.
- common_mistake. 1. Choosing 'copyIndex' for the first hotspot:
copyIndexis a function used within a copy loop to get the current iteration, not to define the loop itself. The overall structure for defining a copy loop for an array is"copy": [ { "name": ..., "count": ..., "input": {...} } ]. Choosing 'copyIndex' here would result in an incorrect template structure.
- Choosing 'dependsOn' for either hotspot:
dependsOnis used to specify dependencies between resources, ensuring resources are deployed in the correct order. It has no role in dynamically generating multiple instances of a property or assigning unique numerical identifiers like LUNs. - Choosing 'copy' for the second hotspot:
copydefines a loop structure. Thelunproperty expects an integer value, not another loop definition. Placing 'copy' here would be syntactically incorrect and would not assign a unique LUN.
Concept tested. The core concept tested is the ability to use Azure Resource Manager (ARM) template 'copy' loops and the copyIndex() function to dynamically create multiple instances of a resource property (in this case, multiple data disks) and assign unique identifiers (LUNs) to them during deployment.
Reference. https://docs.microsoft.com/azure/azure-resource-manager/templates/copy-loops
Topics
Community Discussion
No community discussion yet for this question.
