exam questions

Exam AZ-400 All Questions

View all questions & answers for the AZ-400 exam

Exam AZ-400 topic 7 question 2 discussion

Actual exam question from Microsoft's AZ-400
Question #: 2
Topic #: 7
[All AZ-400 Questions]

You have a project in Azure DevOps.
You create the following YAML template named Template1.yml.
steps:
- script: npm install
- script: yarn install
- script: npm run compile
You create the following pipeline named File1.yml.
parameters:
usersteps:
- task: MyTask@1
- script: echo Done
You need to ensure that Template1.yaml runs before File1.yml.
How should you update File1.yml?

  • A. parameters: usersteps: extends: template: template1.yml - task: MyTask@1 - script: echo Done
  • B. template: template1.yml parameters: usersteps: - task: MyTask@1 - script: echo Done
  • C. extends: template: templatel.yml parameters: usersteps: - task: MyTask@1 - script: echo Done
  • D. parameters: usersteps: - template: templatel.yml - task: MyTask@1 - script: echo Done
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
jay158
Highly Voted 3 years, 1 month ago
Selected Answer: C
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#extend-from-a-template
upvoted 15 times
postuond
2 months, 3 weeks ago
I would choose C, even though there is a typo and instead of Template1.yml it is templatel.yml.
upvoted 1 times
...
...
adityagoel26
Highly Voted 2 years, 2 months ago
Answer should be B. template: template1.yml Explanation: To ensure that the Template1.yaml runs before File1.yml, you can use the template keyword in File1.yml to reference Template1.yaml. The parameters section is used to pass values to the referenced template. In this case, we need to pass the usersteps parameter from File1.yml to Template1.yaml. Therefore, we need to include the parameters section in File1.yml, and reference the usersteps parameter in Template1.yaml. The correct syntax is shown in option B. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#step-reuse
upvoted 12 times
...
shivakp
Most Recent 7 months, 2 weeks ago
D) steps: - script: echo This script runs before the template's steps, only on Windows. - template: templates/npm-steps.yml # Template reference - script: echo This step runs after the template's steps.
upvoted 1 times
...
vsvaid
1 year, 5 months ago
Cannot figure out how C will work. Looked at the links as well. Not sure which one is answer.
upvoted 1 times
...
gabo
1 year, 8 months ago
Selected Answer: D
As per https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops&pivots=templates-includes#extend-from-a-template D is a correct option to run the template1.yml code before the steps of File1.yml
upvoted 7 times
...
gabo
1 year, 8 months ago
For those choosing option B, pls note that the syntax is wrong although your thinking of include is correct. The correct syntax in that case should be parameters: steps: - template: template1.yml - task: MyTask@1 - script: echo Done
upvoted 2 times
...
syu31svc
2 years, 10 months ago
Selected Answer: C
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops Answer is C
upvoted 1 times
...
Sunny1710
3 years ago
Correct
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...