Skip to content

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?

  1. A@metadata({ allowedValues: [ 'Standard_D2s_v5', 'Standard_D4s_v5' ] })
  2. B@minLength(15)
  3. C@description('Standard_D2s_v5 or Standard_D4s_v5')
  4. D@allowed([ 'Standard_D2s_v5', 'Standard_D4s_v5' ])
Show the answer and why
  • A@metadata({ allowedValues: [ 'Standard_D2s_v5', 'Standard_D4s_v5' ] })

    Incorrect

    @metadata only attaches descriptive data to the parameter; Resource Manager doesn't validate values against it.

  • B@minLength(15)

    Incorrect

    A length limit checks how long the string is, not whether it's one of the two permitted sizes.

  • C@description('Standard_D2s_v5 or Standard_D4s_v5')

    Incorrect

    A description documents the parameter for users and tools; it doesn't reject other values.

  • D@allowed([ 'Standard_D2s_v5', 'Standard_D4s_v5' ])

    Correct

    @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.

Question 2 · choose 1

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?

  1. AThe deployment ran in incremental mode
  2. BThe deployment used a parameters file from another environment
  3. CThe template's storage account used the existing keyword
  4. 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.

Question 3 · choose 1

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?

  1. Aaz bicep build --file main.json
  2. Baz deployment group export --name main.json
  3. Caz bicep decompile --file main.json
  4. 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.

Question 4 · choose 1

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?

  1. AThree different names, because uniqueString is random on each run
  2. BOne name for both RG-A deployments, another name in RG-B
  3. COne name for the three, because the subscription is the same
  4. 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.

Question 5 · choose 1

After a Bicep deployment, a pipeline needs the blob endpoint of the storage account the file creates (symbolic name stg). What should you add?

  1. Aoutput blobEndpoint string = stg.properties.primaryEndpoints.blob
  2. Bresource blobEndpoint 'Microsoft.Storage/storageAccounts@2023-05-01' existing
  3. Cparam blobEndpoint string = stg.properties.primaryEndpoints.blob
  4. Dvar blobEndpoint = stg.properties.primaryEndpoints.blob
Show the answer and why
  • Aoutput blobEndpoint string = stg.properties.primaryEndpoints.blob

    Correct

    Outputs return values from the deployment, which the pipeline can read.

  • Bresource blobEndpoint 'Microsoft.Storage/storageAccounts@2023-05-01' existing

    Incorrect

    existing references a resource; it doesn't return a value to the caller.

  • Cparam blobEndpoint string = stg.properties.primaryEndpoints.blob

    Incorrect

    Parameters are inputs given before deployment; they can't read deployed values.

  • Dvar blobEndpoint = stg.properties.primaryEndpoints.blob

    Incorrect

    Variables are internal to the file and aren't returned.

Use output to return values such as endpoints or IDs from a deployment. The pipeline reads them from the deployment results.

Question 6 · choose 1

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?

  1. AThe history is unlimited and isn't trimmed
  2. BOld entries are deleted automatically as the history nears 800
  3. CDeployments fail once the history holds 800 entries
  4. 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.

Question 7 · choose 1

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?

  1. A"location": { "type": "securestring" }
  2. B"location": { "type": "string", "defaultValue": "westeurope" }
  3. C"location": { "type": "string", "defaultValue": "[resourceGroup().location]" }
  4. D"location": { "type": "string", "allowedValues": [ "[resourceGroup().location]" ] }
Show the answer and why
  • A"location": { "type": "securestring" }

    Incorrect

    This type changes how the value is handled, not its default, and location isn't secret.

  • B"location": { "type": "string", "defaultValue": "westeurope" }

    Incorrect

    A fixed default ignores the resource group's region.

  • C"location": { "type": "string", "defaultValue": "[resourceGroup().location]" }

    Correct

    resourceGroup().location returns the region of the target resource group as the default.

  • D"location": { "type": "string", "allowedValues": [ "[resourceGroup().location]" ] }

    Incorrect

    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.

Question 8 · choose 1

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?

  1. AExport supports 100 resources; export each resource separately
  2. BExport needs the resource group to be locked first
  3. CExport needs resources that were deployed by templates
  4. 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.

Practise domain 3 →Practise all domains →