AZ-400 Exam QuestionsBrowse all questions from this exam

AZ-400 Exam - Question 324


DRAG DROP -

You have an Azure DevOps pipeline that is used to deploy a Node.js app.

You need to ensure that the dependencies are cached between builds.

How should you configure the deployment YAML? To answer, drag the appropriate values to the correct targets. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Show Answer
Correct Answer:

Discussion

15 comments
Sign in to comment
basiltomato
Jan 28, 2023

I think we are overthinking this one and it's typical MS confusing question. They probably want similar answer as on the given link https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#conditioning-on-cache-restoration So basically install dependencies (npm install) IF cache NOT restored. Therefore: - npm install - ne(variables.CACHE_RESTORED, 'true') The build.sh would be below above script

mfawew223
Dec 10, 2023

To support this, the comments have come to 2 different answers, but one doesnt make sense to design a pipeline that way. The 2 answers can be described as either "if npm is cached, then run build.sh" or "if npm is not cached, install npm". Whats going to happen if the pipeline isnt cached? in the first answer, the pipeline would just stop/fail if npm isnt cached. So how would you have npm cached in the first place? For the 2nd answer, what happens if npm isnt cached? npm gets installed, then we move to the next step. The step being shown isnt a build step. its a step that ensures that npm is installed BEFORE the build.sh uses npm in another step. The only thing this step should be doing is ensuring npm is installed for the rest of the pipeline. Thus, basiltomato's answer is the correct one

Hillah
Jan 17, 2024

You need to ensure that the dependencies are cached between builds. Therefore, we assume that npm is already installed, we only need to cache at build Hence - build.sh - Eq(variables.CACHE_RESTORED, 'true')

wiokito
Jan 23, 2023

i think it should be : - npm install - ne(variables.CACHE_RESTORED, 'true') https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#conditioning-on-cache-restoration

wiokito
Jan 25, 2023

i edit my answer: the goal here is to "ensure" caching so the solution is: - build.sh - Eq(variables.CACHE_RESTORED, 'true')

crymo99
Jan 26, 2023

I believe given answer is correct. - build.sh - ne(variables.CACHE_RESTORED, 'true')

gabo
Sep 28, 2023

This is incorrect. You are building the app if cache is not restored which will cause the pipeline to fail.

mrg998
Jan 23, 2023

Answer is: Npm install - install Eq(variables.CACHE_RESTORED, 'true') - only if cache has been restored https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#conditioning-on-cache-restoration

zellck
Jun 3, 2023

1. build.sh 2. ne(variables.CACHE_RESTORED, 'true') https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#conditioning-on-cache-restoration

gabo
Sep 28, 2023

This is incorrect. You are building the app if cache is not restored which will cause the pipeline to fail.

AlexeyG
Mar 2, 2023

variables: NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages steps: - task: Cache@2 inputs: key: 'nuget | "$(Agent.OS)" | $(Build.SourcesDirectory)/**/packages.lock.json' restoreKeys: | nuget | "$(Agent.OS)" nuget path: $(NUGET_PACKAGES) displayName: Cache NuGet packages Answer on exam $(Build.SourcesDirectory)/**/packages.lock.json' "$(Agent.OS)" $(NUGET_PACKAGES) got this in 02 March 2023 exams. scored 870 marks.

3arle
Jan 22, 2023

at first should be npm install, then build https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#conditioning-on-cache-restoration

Dats1987
Sep 7, 2023

In some scenarios, the successful restoration of the cache should cause a different set of steps to be run. For example, a step that installs dependencies can be skipped if the cache was restored. This is possible using the cacheHitVar task input. Setting this input to the name of an environment variable will cause the variable to be set to true when there's a cache hit, inexact on a restore key cache hit, otherwise it will be set to false. This variable can then be referenced in a step condition or from within a script. In the following example, the install-deps.sh step is skipped when the cache is restored: steps: - task: Cache@2 inputs: key: mykey | mylockfile restoreKeys: mykey path: $(Pipeline.Workspace)/mycache cacheHitVar: CACHE_RESTORED - script: install-deps.sh condition: ne(variables.CACHE_RESTORED, 'true') - script: build.sh

4b31a3a
Dec 4, 2023

The 3 ... means that there is more of the pipline that is not shown, if we presume the parts of the pipline not shown are to do with the deployment we can deduce that we are dealing with the part of the pipeline that handles package installation. Thjere for the answer is - npm install - ne(variables.CACHE_RESTORED, 'true')

gabo
Sep 27, 2023

If you choose to run the build.sh script, then that should run only if Cache is successfully restored, so choose eq(variables.CACHE_RESTORED, 'true')

gabo
Sep 28, 2023

On the other hand if you choose to run npm install, then it should run only if Cache is not restored, so choose ne(variables.CACHE_RESTORED, 'true')

CirusD
Oct 7, 2023

trigger: - master pool: vmImage: 'ubuntu-latest' steps: - checkout: self - task: Cache@2 inputs: key: 'npm | package-lock.json' path: $(Pipeline.Workspace)/.npm cacheHitVar: CACHE_RESTORED - script: npm ci displayName: 'npm ci' condition: ne(variables.CACHE_RESTORED, 'true') - script: npm run build displayName: 'npm build'

varinder82
Nov 29, 2023

Final Answer after going through below comments - npm install - ne(variables.CACHE_RESTORED, 'true')

Kalaisuran
Mar 25, 2024

https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops

4bd3116
May 5, 2024

The Answer is correct: variables: npm_config_cache: $(Pipeline.Workspace)/.npm steps: - task: Cache@2 inputs: key: 'npm | "$(Agent.OS)" | package-lock.json' restoreKeys: | npm | "$(Agent.OS)" path: $(npm_config_cache) cacheHitVar: CACHE_RESTORED - script: ./build.sh condition: ne(variables.CACHE_RESTORED, 'true')

sondrex
Jul 20, 2024

Script: npm install Condition: ne(variables.CACHE_RESTORED, 'true')