Creating Template3 by Defining Bicep Modules That Reuse Logic from Template1 and Template2

Design and implement infrastructure as code (IaC)
Answer Correct answer: C — Bicep modules reference other templates as reusable building blocks, so Template3 must define modules for Template1 and Template2 before wiring their inputs.

You have an Azure subscription. You create two Bicep templates named Template1 and Template2 that will be used to create a virtual machine and a website. You need to create a template named Template3 that will reuse logic from Template1 and Template2. What should you define first?

  1. outputs
  2. resources
  3. modules Correct Answer
  4. parameters

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

Bicep modules are the unit of reusable logic across templates, so Template3 must first declare modules that reference Template1 and Template2 before those modules can be instantiated with parameters and consumed as building blocks.

Two Bicep templates, Template1 and Template2, deploy a virtual machine and a website respectively, and a third template named Template3 must reuse logic from both. Reuse across templates in Bicep is achieved through a specific construct that has to exist before anything can reference it.

Starting with parameters, outputs, or a resources block. Those are the ordinary contents of any template, but none of them create a reusable reference to another template, so Template3 would duplicate logic rather than reuse it.

Community Discussion (3 comments)

p2006 👍 1 Selected: C
https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/modules
Mattt 👍 1 Selected: C
Just like Terraform we should define modules to make the code reusable
uncledana 👍 2
C is answer

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

The requirement is that Template3 reuses logic from Template1 and Template2, and Bicep provides a specific construct for composing templates: modules. A module references another Bicep or ARM template as a callable building block, exposing its parameters and outputs so the calling template can wire them together. Because a module reference must exist before it can be used, the modules definition is the first thing to declare in Template3. The vote was unanimous at 100 for C. p2006 supplied the authoritative Microsoft Learn page on Bicep modules, and Mattt drew the right analogy by noting that this is the same modular reuse pattern as Terraform modules, which confirms the concept is about composition rather than about any single template section.

Why the Other Options Are Wrong

Parameters (D) are inputs passed into a template, and declaring them says nothing about pulling in other templates, so a Template3 with only parameters would still have to duplicate the VM and website logic. Outputs (A) are the values a template exports to its caller, which is a data flow out of the template rather than a mechanism for composing templates, and in Bicep outputs cannot be declared at the top level in a way that constitutes reuse. The resources block (B) declares the actual infrastructure items a template deploys, so using it in Template3 would mean writing the virtual machine and website again inline, which is duplication rather than the reuse the question asks for.

Community Comment Notes

The community was unanimous at 100 for C, and both substance comments identify modules as the reuse construct. p2006 linked the official Bicep modules documentation, which is the verifiable basis for the answer. Mattt's comment adds the useful framing that modules are to Bicep what modules are to Terraform, which is exactly the right mental model for understanding why modules must be defined before use. The absence of dissent reflects that the other three options are familiar template sections that simply do not perform cross-template composition.

Official Reference

Related Analysis

Practice All AZ-400 Questions

Access 100 questions with complete answers and detailed explanations.

View Full AZ-400 Practice Test →

← Back to AZ-400 Study Guide