exam questions

Exam AZ-400 All Questions

View all questions & answers for the AZ-400 exam

Exam AZ-400 topic 7 question 90 discussion

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

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 Suggested Answer Hide Answer
Suggested Answer:

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
basiltomato
Highly Voted 2 years, 3 months ago
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
upvoted 37 times
Hillah
1 year, 3 months ago
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')
upvoted 2 times
...
mfawew223
1 year, 4 months ago
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
upvoted 2 times
...
...
wiokito
Highly Voted 2 years, 3 months ago
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
upvoted 9 times
wiokito
2 years, 3 months ago
i edit my answer: the goal here is to "ensure" caching so the solution is: - build.sh - Eq(variables.CACHE_RESTORED, 'true')
upvoted 4 times
...
...
Mattt
Most Recent 6 months, 4 weeks ago
The answer is - npm install - ne(variables.CACHE_RESTORED, 'true') if the cache is empty, we sould run npm install. Build should be run after that without any condition steps: - task: Cache@2 inputs: key: mykey | mylockfile restoreKeys: mykey path: $(Pipeline.Workspace)/mycache cacheHitVar: CACHE_RESTORED - script: npm install condition: ne(variables.CACHE_RESTORED, 'true') - script: build.sh
upvoted 2 times
...
sondrex
9 months, 2 weeks ago
Script: npm install Condition: ne(variables.CACHE_RESTORED, 'true')
upvoted 1 times
...
4bd3116
12 months ago
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')
upvoted 2 times
...
Kalaisuran
1 year, 1 month ago
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops
upvoted 1 times
...
4b31a3a
1 year, 5 months ago
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')
upvoted 3 times
...
varinder82
1 year, 5 months ago
Final Answer after going through below comments - npm install - ne(variables.CACHE_RESTORED, 'true')
upvoted 1 times
...
CirusD
1 year, 7 months ago
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'
upvoted 1 times
...
gabo
1 year, 7 months ago
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')
upvoted 1 times
gabo
1 year, 7 months ago
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')
upvoted 1 times
...
...
Dats1987
1 year, 8 months ago
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
upvoted 2 times
...
zellck
1 year, 11 months ago
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
upvoted 5 times
gabo
1 year, 7 months ago
This is incorrect. You are building the app if cache is not restored which will cause the pipeline to fail.
upvoted 1 times
...
...
AlexeyG
2 years, 2 months ago
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.
upvoted 3 times
...
crymo99
2 years, 3 months ago
I believe given answer is correct. - build.sh - ne(variables.CACHE_RESTORED, 'true')
upvoted 6 times
gabo
1 year, 7 months ago
This is incorrect. You are building the app if cache is not restored which will cause the pipeline to fail.
upvoted 1 times
...
...
mrg998
2 years, 3 months ago
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
upvoted 4 times
...
3arle
2 years, 3 months ago
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
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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago