Exclude files from Azure ML snapshot with .amlignore
Short answer
D Copy the .gitignore contents into .amlignore so the 20 files are excluded from the Azure Machine Learning snapshot sent to compute.
Question
Key Takeaways
Azure Machine Learning uses .amlignore, not .gitignore, to decide which training script files are excluded from the snapshot uploaded to compute targets. Copying the 20 file names from .gitignore into .amlignore is the correct fix, because when .amlignore is present it supersedes .gitignore for snapshot filtering.
Expert Analysis
The presence of.amlignore means Azure Machine Learning uses that file to determine which source files are excluded from the snapshot sent to compute. Entries added only to.gitignore therefore do not change the snapshot. Copying those exclusion patterns into.amlignore applies them to the training source upload and prevents the 20 named files from being copied.
The deciding mechanism here is that Azure Machine Learning builds the source snapshot for a training run from the training scripts directory using .amlignore as the authoritative exclusion list, and .amlignore supersedes .gitignore entirely when both exist. Because this directory already contains a .amlignore, the 20 file names written into .gitignore are read only by Git's local working tree rules and never reach the snapshot upload, which is exactly why the files keep arriving on the compute target. Option D fixes the mismatch directly: copying the contents of .gitignore into .amlignore puts the 20 exclusion patterns where the snapshot builder actually reads them, so those files are filtered out before the source is sent to compute.
Option A fails because relocating .gitignore into ./logs changes nothing about snapshot semantics. ./logs is just another subdirectory in the training scripts tree, and the snapshot logic consults a .amlignore at the directory root, not a .gitignore parked inside a subfolder; the 20 files would still be included. Option B has the identical defect for ./outputs: dropping .gitignore into ./outputs neither creates an exclusion mechanism for the snapshot nor removes the controlling root .amlignore, so the copy operation to the compute targets continues unchanged. Option C inverts the source and destination — moving .amlignore contents into .gitignore would leave .amlignore holding only its original patterns (if any) while the new 20-file rules sit in a file the snapshot builder ignores, so the exclusion still never applies.
The concrete pattern worth carrying away: in Azure Machine Learning, .amlignore is the run-snapshot counterpart of .gitignore, and when it is present it fully replaces .gitignore for the purposes of which source files are uploaded to the compute target. A practical worked example using this scenario's entities: the 100-file directory with its ./outputs and ./logs subdirectories would, under default snapshot behavior, exclude ./outputs contents automatically (outputs are treated as run artifacts), while any file listed only in .gitignore such as a large dataset CSV among the 20 would still be snapshotted. The fix is to place those 20 names in .amlignore, which is precisely what option D accomplishes by copying the already-correct .gitignore entries across.
Exam Strategy
When a question mentions both .amlignore and .gitignore in an Azure Machine Learning training snapshot, remember that .amlignore overrides .gitignore for the snapshot sent to compute — so any answer that only moves or edits .gitignore is a distractor. Pick the option that places the exclusion patterns in .amlignore, and watch for direction-of-copy traps where the source and destination files are swapped.
Related Analysis
Practice All AI-300 Questions
Access 49 questions with complete answers and detailed explanations.
View Full AI-300 Practice Test →