AZ-104 · Domain 3: Deploy and manage Azure compute resources · 24% of the exam
Task 3.1: Automate deployment of resources by using Azure Resource Manager (ARM) templates or Bicep files
Reading and editing ARM templates and Bicep files, deploying them, exporting a deployment as a template and converting a template to Bicep.
Study it
Reading, editing and deploying ARM templates and Bicep files
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the Microsoft documentation page that proves it.
Question 1 · choose 1
A Bicep file declares:
param vmSize string = 'Standard_D2s_v5'
Deployments must fail validation unless vmSize is Standard_D2s_v5 or
Standard_D4s_v5. What should you add directly above the parameter?
@allowed defines the permitted values, and a deployment with any other value fails validation.
Parameter decorators in Bicep add constraints and metadata. @allowed lists the values a parameter accepts; @minLength, @maxLength, @minValue and @maxValue bound it; @description and @metadata only document it.
An engineer deployed a template that defines only a storage account to resource group RG-Web. After the deployment, a VM that already existed in RG-Web was gone. Which setting caused this?
AThe deployment ran in incremental mode
BThe deployment used a parameters file from another environment
CThe template's storage account used the existing keyword
DThe deployment ran in complete mode
Show the answer and why
AThe deployment ran in incremental mode
Incorrect
Incremental mode, the default, leaves resources that aren't in the template unchanged.
BThe deployment used a parameters file from another environment
Incorrect
Parameter values change settings of the listed resources; they don't remove resources the template doesn't list.
CThe template's storage account used the existing keyword
Incorrect
The existing keyword references a resource without deploying it; it can't delete other resources.
DThe deployment ran in complete mode
Correct
In complete mode, Resource Manager deletes resources in the resource group that the template doesn't specify.
Incremental mode adds or updates what the template defines and leaves the rest. Complete mode deletes resources not in the template; Microsoft recommends deployment stacks for deletions.
You exported resource group RG-Data as an ARM JSON template, main.json. The team now maintains its infrastructure in Bicep. Which command produces a Bicep file from main.json?
Aaz bicep build --file main.json
Baz deployment group export --name main.json
Caz bicep decompile --file main.json
Daz bicep format --file main.json
Show the answer and why
Aaz bicep build --file main.json
Incorrect
bicep build goes the other way: it compiles a Bicep file into an ARM JSON template.
Baz deployment group export --name main.json
Incorrect
Exporting writes the template of a past deployment as JSON; it doesn't convert anything to Bicep.
Caz bicep decompile --file main.json
Correct
decompile converts an ARM JSON template into a Bicep file on a best-effort basis, which you then review and fix.
Daz bicep format --file main.json
Incorrect
bicep format tidies the layout of a Bicep file; it doesn't read JSON templates.
Decompiling turns ARM JSON into Bicep as a starting point. The result can need fixes, such as names and expressions the converter can't infer, so review it before deploying.
A template names a storage account with:
"name": "[concat('st', uniqueString(resourceGroup().id))]"
You deploy it twice to RG-A and once to RG-B, in the same subscription. What
names result?
AThree different names, because uniqueString is random on each run
BOne name for both RG-A deployments, another name in RG-B
COne name for the three, because the subscription is the same
DNo name, because concat can't take a function as an argument
Show the answer and why
AThree different names, because uniqueString is random on each run
Incorrect
uniqueString isn't random; it's a hash of its inputs, so the same input gives the same result.
BOne name for both RG-A deployments, another name in RG-B
Correct
The hash of RG-A's ID is the same both times, so the second deployment updates the same account; RG-B's ID hashes differently.
COne name for the three, because the subscription is the same
Incorrect
resourceGroup().id includes the resource group name, so RG-A and RG-B produce different hashes.
DNo name, because concat can't take a function as an argument
Incorrect
Template functions can be nested, and concat accepts the string uniqueString returns.
uniqueString returns a 13-character deterministic hash of its parameters. Seeding it with resourceGroup().id gives a name that's stable for repeat deployments to one resource group and different in each resource group.
A pipeline deploys to the same resource group dozens of times a day. Someone worries that deployments will start failing when the history fills up. What actually happens?
AThe history is unlimited and isn't trimmed
BOld entries are deleted automatically as the history nears 800
CDeployments fail once the history holds 800 entries
DEach deployment overwrites the previous one in the history
Show the answer and why
AThe history is unlimited and isn't trimmed
Incorrect
There's a limit of 800 per resource group.
BOld entries are deleted automatically as the history nears 800
Correct
The history is limited to 800 deployments per resource group, and older ones are removed automatically.
CDeployments fail once the history holds 800 entries
Incorrect
Azure deletes old entries automatically as the limit nears, so deployments keep working.
DEach deployment overwrites the previous one in the history
Incorrect
Deployments are kept as separate entries up to the limit.
Deployment history per resource group is limited to 800 deployments. As the limit nears, Azure deletes older deployments from the history automatically.
You're editing an ARM template so that resources go to the region of the target resource group unless someone passes a location. How should the location parameter be defined?
allowedValues lists permitted values and doesn't provide a default.
Parameters can take a defaultValue expression. Using resourceGroup().location keeps resources in the group's region while still letting a caller override it.
You export the template of a resource group that holds 250 resources, and the portal returns an error. What explains it, and what can you do?
AExport supports 100 resources; export each resource separately
BExport needs the resource group to be locked first
CExport needs resources that were deployed by templates
DExport supports up to 200 resources; export a subset of them
Show the answer and why
AExport supports 100 resources; export each resource separately
Incorrect
The limit is 200 resources, not 100.
BExport needs the resource group to be locked first
Incorrect
Locks have nothing to do with exporting a template.
CExport needs resources that were deployed by templates
Incorrect
Export from the resource group captures the current state of resources, whatever created them.
DExport supports up to 200 resources; export a subset of them
Correct
Export from a resource group has a 200-resource limit, so select fewer resources or export them in batches.
Exporting a template from a resource group is limited to 200 resources, and the exported template may lack some password parameters you must add before redeploying. Exporting from deployment history returns the original template instead.