mediummultiple choiceObjective-mapped

A PowerShell script runs on an Azure VM every night and uses Azure CLI commands to create tags and VM resources in another subscription. The script cannot store a password or client secret. What should it use to authenticate to Azure?

Question 1mediummultiple choice
Full question →

A PowerShell script runs on an Azure VM every night and uses Azure CLI commands to create tags and VM resources in another subscription. The script cannot store a password or client secret. What should it use to authenticate to Azure?

Answer choices

Why each option matters

Good practice is not just finding the correct option. The wrong answers often show the exact trap the exam wants you to fall into.

A

Distractor review

az login with a username and password.

A username and password requires credential storage and is not appropriate for secretless automation.

B

Best answer

az login --identity.

The Azure CLI can sign in with the VM's managed identity by using az login --identity. That allows the script to authenticate without storing a password or client secret. After sign-in, the identity can be granted access to the target subscription or resource group, which makes the solution both secure and automation-friendly for nightly jobs.

C

Distractor review

Connect-AzAccount with device code authentication.

Device code authentication is interactive and not suitable for unattended nightly automation on a VM.

D

Distractor review

An app registration secret stored in a PowerShell variable.

A secret in a variable is still a secret on the machine and violates the stated security requirement.

Common exam trap

Common exam trap: NAT rules depend on direction and matching traffic

NAT is not only about the public address. The inside/outside interface roles and the ACL or rule that matches traffic are just as important.

Technical deep dive

How to think about this question

NAT questions usually test address translation, overload/PAT behaviour, static mappings and whether the right traffic is being translated. Read the interface direction and address terms carefully.

KKey Concepts to Remember

  • Static NAT maps one inside address to one outside address.
  • PAT allows many inside hosts to share one public address using ports.
  • Inside local and inside global describe the private and translated addresses.
  • NAT ACLs identify traffic for translation, not always security filtering.

TExam Day Tips

  • Identify inside and outside interfaces first.
  • Check whether the scenario needs static NAT, dynamic NAT or PAT.
  • Do not confuse NAT matching ACLs with normal packet-filtering intent.

Related practice questions

Related AZ-104 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

More questions from this exam

Keep practising from the same exam bank, or move into a focused topic page if this question exposed a weak area.

FAQ

Questions learners often ask

What does this AZ-104 question test?

Static NAT maps one inside address to one outside address.

What is the correct answer to this question?

The correct answer is: az login --identity. — The correct approach is az login --identity because it uses the Azure VM's managed identity instead of a stored credential. This is the standard pattern for unattended scripts running inside Azure. Once authenticated, the script can operate against the appropriate subscription as long as the managed identity has the necessary RBAC permissions. It is a secure and low-maintenance way to automate Azure CLI tasks. Why others are wrong: Using a username/password or an app secret means credentials must be stored somewhere, which the question explicitly forbids. Device-code authentication requires a person to complete the sign-in flow and is unsuitable for scheduled automation. The core idea is to let the VM authenticate as itself using managed identity.

What should I do if I get this AZ-104 question wrong?

Then try more questions from the same exam bank and focus on understanding why the wrong options are tempting.

Discussion

Loading comments…

Sign in to join the discussion.