Repository navigation
[Feature Request] Global --read-only Mode for Azure CLI #32974
Description
Preconditions
- No need to upgrade Python SDK or the Python SDK is ready.
Related command
No response
Resource Provider
N/A
Description of Feature or Work Requested
I would like to request the implementation of a global read-only ("sandbox") mode for the Azure CLI, similar to the behavior of the Azure MCP server.
When enabled, this mode should restrict the CLI to only executing list, show, and get commands, effectively blocking any commands that would create, update, or delete resources.
Motivation
With the rise of unsupervised coding agents, Copilot CLI, and MCP-based integrations, there is a growing need for a "safety rail."
Safety: Prevent agents from accidentally modifying or deleting production infrastructure during diagnostic tasks.
Trust: Allow users to grant CLI access to AI tools with the confidence that no state-changing operations will be performed.
Efficiency: Avoid the complexity of creating specific "Reader" RBAC roles for every temporary session or agent environment. Not always users have the needed right on Entra ID.
If a user attempts a command like az group delete, the CLI should intercept the call and return an error:
Error: Azure CLI is in read-only mode. Command execution blocked.
Minimum API Version Required
N/A
Swagger PR link / SDK link
N/A
Request Example
No response
Target Date
2026-12-31
PM Contact
N/A
Engineer Contact
N/A
Additional context
No response
Activity
yonzhan commentedon Mar 16, 2026
Thank you for opening this issue, we will look into it.
github-actions commentedon Mar 16, 2026
This issue is related to security. Please pay attention.
Powered by issue-sentinel
5 remaining items
microsoft-github-policy-service commentedon Sep 17, 2026
🔔 Routing this issue to @Azure/act-identity-squad.
x-engineering-agent commentedon Sep 20, 2026
Hi Danilo Spinelli (@gunzip), a quick follow-up on the information requested earlier. Could you share the outstanding details when you have a chance? Please redact any credentials or other sensitive values.
I'll pick this up automatically once you reply.
gunzip commentedon Sep 21, 2026
Hi @x-enginerring-agent, thanks for the follow-up. This is an enhancement request (not a defect), anyway, here are the requested details.
Version/platform/extensions
Proposed usage
az config set core.read_only=trueorAZURE_CLI_READ_ONLY=trueaz --read-only <command>Observed behavior
N/A — enhancement only. With the mode off,
az group delete -n <rg>runs after confirmation.Safe acceptance cases (disposable RG
rg-ro-testcreated once with the mode off)az group list/az group show -n rg-ro-testaz vm list -g rg-ro-test/az account showaz rest --method GET --url ...az group create .../az group delete ...az vm create .../az deployment group create ...az keyvault secret set .../az role assignment create ...az rest --method DELETE --url ...az aks nodepool add ...)Expected error:
Error: Azure CLI is in read-only mode. Command execution blocked.x-engineering-agent commentedon Sep 21, 2026
Enhancement analysis: global read-only mode
The sanitized author reply supplies sufficient requirements; no further reproduction request is needed for this enhancement. Reported context: Azure CLI/core 2.87.0, macOS 26.5.2 arm64. The current write-enabled behavior is that
az group delete -n <rg>proceeds after confirmation. Requested behavior is opt-in read-only enforcement, withError: Azure CLI is in read-only mode. Command execution blocked.for denied commands. This is not a claimed regression or a locally reproduced failure.Ownership and source evidence (read-only inspection of
37c9b6b4ee3363e6333450e85c5ee25ee83ffe1a):send_raw_request. REST arguments default to GET and also expose mutating methods; command-name filtering alone cannot classifyaz rest.Repository inference resolves the verified REST source to the built-in
utilmodule in Azure/azure-cli. The primary implementation component is Core because the requirement is global. Extension examples are acceptance coverage, not grounds for an azure-cli-extensions tracker.Proposed implementation contract
core.read_only=true,AZURE_CLI_READ_ONLY=true, and the leading formaz --read-only <command>. Resolve enablement before command discovery/dispatch as necessary. Any enabled source keeps the invocation read-only: absence or a false value elsewhere must not lower it, and there must be no disabling counterpart to the flag. Preserve normal behavior when off; document boolean parsing and configuration lifecycle.az group list,az group show -n rg-ro-test,az vm list -g rg-ro-test, andaz account show. Use conservative, explicit read-operation classification; do not treat an arbitrary name containingget,list, orshowas proof of safety. Deny unclassified operations and mutation verbs beyond just create/update/delete, including set/add. For REST, explicitly classify the effective method (including case normalization and default GET); allow GET and block DELETE/PUT/POST/PATCH. Do not infer that every POST or every extension read-looking command is safe.--yes,--no-wait, or changes through the CLI that lower an active read-only setting must not bypass enforcement.Validation for the implementation worker: add offline mocked coverage in the existing core/parser/command suites for all three opt-in paths, enablement precedence, leading/global flag parsing, allowed reads, each denied family, REST default/case variants, extension/override behavior, and unchanged mode-off behavior. Assert denied commands never reach confirmation, validators, handlers, or request transmission. Do not execute the reporter's resource-changing examples against Azure. This triage ran no local tests or issue commands.
Generation classification: the proposed enforcement belongs in handwritten CLI core (and a handwritten REST adapter only if needed), not a fabricated
command_modules/coredirectory. Do not edit generatedaaz/<profile>/files. The following repository-owned Codegen protocol applies if implementation discovers a necessary generated-command change.PR title & description format (required)
This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.
Use this EXACT PR title (copy verbatim, do not reword):
Keep the backticks around the command and the
Fix #32974:prefix. You may only adjust the wording after the command (the final summary) if the fix changes; the[Core]prefix, issue link, and backticked command must stay.Description — follow the PR template and fill in:
Fixes Azure/azure-cli#32974.az ...command this affects.[Core] `az <command>`: <note>.Mandatory Codegen execution protocol
Before editing implementation files, determine whether the affected
corecommand is AAZ-generated. Files underaaz/<profile>/are generated output and must never be patched directly, including by an AI agent. Check outAzure/aazbesideAzure/azure-rest-api-specs,Azure/aaz-dev-tools, and the downstream repository. API-schema defects start in the specification; command naming, grouping, arguments, API-version selection, help, and examples belong in the durableAzure/aazcommand model; non-modelable client behavior belongs in a handwritten subclass or wrapper incustom.py, registered fromcommands.py. X Engineering Agent creates and promotes the corresponding durableAzure/aazsource pull request before it promotes downstream generated output.Follow the Azure CLI repository's Codegen workflow and the aaz-dev setup documentation. Set up the checked-out repositories with
azdev setup. Usegenerateonly when importing or redesigning command models from Swagger/TypeSpec. For an existing module whose durableAzure/aazmodel has been updated, render that model withregenerate:You MUST actually run the generator; do not merely describe it or imitate its output. If the AAZ/specification checkout, local source change, credentials, or generator is unavailable, stop and report the blocker instead of editing generated files. Inspect
_aaz_infoprovenance and the complete regenerated diff, then run focusedazdev style,azdev linter, andazdev testvalidation. For an extension, also update its version andHISTORY.rst, preserveazext_metadata.jsoncompatibility, and let release automation updatesrc/index.json.x-engineering-agent commentedon Sep 21, 2026
Thanks Danilo Spinelli (@gunzip) for the version, proposed switches, and acceptance cases. Understood: this is an enhancement request, not a defect in an existing read-only mode. There is no need to provide another failing-command reproduction.
Before this can become a bounded implementation proposal for the owning maintainers, please clarify these remaining policy decisions:
For the remaining cases, a small
operation | allowed or blocked | reasontable is sufficient; the existing list/show/create/delete examples do not need to be repeated. The owning maintainers will need to agree on this cross-cutting behavior before implementation; I am not starting an automated bug-fix PR for the enhancement.I'll pick this up automatically once you reply.
microsoft-github-policy-service commentedon Sep 21, 2026
🔔 Routing this issue to @Azure/act-identity-squad.
x-engineering-agent commentedon Sep 24, 2026
Hi, a friendly reminder about the outstanding checklist above. When you have a chance, could you share the missing evidence already requested? We'll pick this up automatically once you reply.
mahauber commentedon Sep 28, 2026
Human pls
isra-fel commentedon Oct 1, 2026
Related topic: Microsoft offers Conditional Access for agents that controls how agents access resources protected by Microsoft Entra ID.
https://learn.microsoft.com/en-us/entra/identity/conditional-access/agent-id
x-engineering-agent commentedon Oct 19, 2026
This is a feature request, not a regression: the reporter has already specified proposed switches and acceptance cases. The CLI registers global arguments in core, loads core and extension commands into one command table, and
az restpasses its selected HTTP method to request dispatch. A command-name-only allowlist cannot cover the proposed REST-method and extension cases. A client-side guard also cannot replace server-enforced, least-privilege authorization for preventing writes outside the CLI.Next action: Azure CLI and identity maintainers should decide whether this is a best-effort CLI safety rail or an enforceable security requirement, then define how the policy covers core commands, extensions, and
az rest. No additional reproduction details or bug-fix job are warranted for this design decision.