Bicep is a simple language to write Azure infrastructure as code. It helps you create and manage Azure resources easily without complex JSON.
Click to reveal answer
beginner
How do you declare a resource in Bicep?
You use the resource keyword followed by a name, type, and properties. For example: resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = { name: 'mystorage', location: 'eastus' }
Click to reveal answer
intermediate
What is a module in Bicep?
A module is a separate Bicep file you can reuse. It helps organize code by splitting complex templates into smaller parts.
Click to reveal answer
intermediate
How do you use a module in a Bicep file?
You declare it with the module keyword, give it a name, specify the path to the module file, and pass parameters if needed. Example: module myModule './module.bicep' = { params: { param1: 'value' } }
Click to reveal answer
intermediate
Why use modules in Bicep templates?
Modules make your templates easier to manage, reuse, and test. They help keep code clean and reduce mistakes by separating concerns.
Click to reveal answer
Which keyword is used to declare a resource in Bicep?
Aresource
Bmodule
Cparam
Dvar
✗ Incorrect
The resource keyword declares Azure resources in Bicep.
What file extension do Bicep files use?
A.azcli
B.json
C.bicep
D.yaml
✗ Incorrect
Bicep files use the .bicep extension.
How do you include a module in a Bicep file?
AUsing the <code>resource</code> keyword
BUsing the <code>module</code> keyword
CUsing the <code>import</code> keyword
DUsing the <code>include</code> keyword
✗ Incorrect
Modules are included with the module keyword.
What is the main benefit of using modules in Bicep?
AFaster deployment speed
BAutomatic resource scaling
CImproved security
DBetter code organization and reuse
✗ Incorrect
Modules help organize code and allow reuse across templates.
Which of these is a valid way to pass parameters to a module?
Aparams: { param1: 'value' }
Bparameters: { param1: 'value' }
Cargs: { param1: 'value' }
Dinputs: { param1: 'value' }
✗ Incorrect
Parameters are passed using the params property.
Explain how to declare and use a module in a Bicep template.
Think about how you include and configure reusable parts.
You got /4 concepts.
Describe the benefits of using Bicep modules in managing Azure infrastructure.
Consider how splitting code helps in real life projects.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a module in Bicep?
easy
A. To reuse and organize infrastructure code by calling other Bicep files
B. To define variables inside a Bicep file
C. To store output values only
D. To create a new Azure subscription
Solution
Step 1: Understand what a module does
A module in Bicep is a way to include and reuse other Bicep files, helping organize code.
Step 2: Compare options to the definition
Only To reuse and organize infrastructure code by calling other Bicep files correctly describes modules as reusable code blocks. Variables and outputs are different concepts, and creating subscriptions is unrelated.
Final Answer:
To reuse and organize infrastructure code by calling other Bicep files -> Option A
Quick Check:
Module = reusable code block [OK]
Hint: Modules call other files to reuse code easily [OK]
Common Mistakes:
Confusing modules with variables
Thinking modules only store outputs
Believing modules create Azure subscriptions
2. Which of the following is the correct syntax to declare a module in Bicep?
easy
A. module myModule = 'module.bicep' {}
B. module myModule 'module.bicep' = {}
C. module 'myModule' = module.bicep {}
D. module 'myModule' 'module.bicep' {}
Solution
Step 1: Recall module declaration syntax
The correct syntax is: module <name> '<path>' = {}.
Step 2: Match options to syntax
module myModule 'module.bicep' = {} matches the correct syntax exactly. Other options have misplaced quotes or assignment operators.
Final Answer:
module myModule 'module.bicep' = {} -> Option B
Quick Check:
module name 'file' = {} [OK]
Hint: Use: module name 'file.bicep' = {} [OK]
Common Mistakes:
Putting quotes around the module name
Using = before the file path
Omitting the equals sign
3. Given this Bicep code snippet, what will be the output value of moduleOutput?
A. An error because outputs cannot be accessed from modules
B. The module file path 'storage.bicep'
C. The name of the storage account defined inside storage.bicep
D. The string 'storage1'
Solution
Step 1: Understand module outputs
Modules can expose outputs which can be accessed using moduleName.outputs.outputName.
Step 2: Analyze the code snippet
The output moduleOutput gets the value of storageAccountName from the module's outputs, which is the storage account name defined inside storage.bicep.
Final Answer:
The name of the storage account defined inside storage.bicep -> Option C
Quick Check:
module.outputs = module data access [OK]
Hint: Access module outputs with moduleName.outputs.outputName [OK]
A. Incorrect keyword 'params' should be 'parameters'
B. Module name cannot contain numbers
C. Module file path must be absolute
D. Missing equals sign after 'name'
Solution
Step 1: Check parameter passing syntax in modules
In Bicep, module parameters can be passed directly as properties (e.g., location: 'eastus') or nested under parameters: { ... }. params is not a valid keyword.
Step 2: Identify the error
The code uses invalid params:, which should be parameters: for nested parameters.
Final Answer:
Incorrect keyword 'params' should be 'parameters' -> Option A
Quick Check:
parameters: { } for nested params [OK]
Hint: Use 'parameters:' not 'params' for nested params [OK]
Common Mistakes:
Using 'params' instead of 'parameters'
Thinking module names cannot contain numbers
Believing file paths must be absolute
5. You want to create a reusable Bicep module for a virtual network that accepts a parameter for the address prefix and outputs the subnet ID. How should you define the module's parameter and output to follow best practices?
hard
A. Declare the address prefix as an output and subnet ID as a parameter
B. Use a variable for address prefix and no output since subnet ID is internal
C. Hardcode the address prefix and output the subnet name instead of ID
D. Declare a param addressPrefix string and an output subnetId string in the module file
Solution
Step 1: Define parameters for input values
Best practice is to declare inputs as parameters so the module is flexible. Here, param addressPrefix string allows passing different address prefixes.
Step 2: Define outputs for important results
Outputs share useful info back to the caller. The subnet ID is important to output as output subnetId string.
Final Answer:
Declare a param addressPrefix string and an output subnetId string in the module file -> Option D
Quick Check:
Parameters input, outputs share results [OK]
Hint: Use param for inputs, output for results [OK]
Common Mistakes:
Using variables instead of parameters for inputs
Not outputting needed resource IDs
Mixing parameters and outputs roles
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.