Skip to content

Quantum: Update user create/delete operation - #10282

Draft
Pavel Braginskiy (pavelbraginskiy) wants to merge 30 commits into
Azure:mainfrom
pavelbraginskiy:v-pavelbra/53910-user-add-remove
Draft

Quantum: Update user create/delete operation#10282
Pavel Braginskiy (pavelbraginskiy) wants to merge 30 commits into
Azure:mainfrom
pavelbraginskiy:v-pavelbra/53910-user-add-remove

Conversation

@pavelbraginskiy

@pavelbraginskiy Pavel Braginskiy (pavelbraginskiy) commented Aug 31, 2026

Copy link
Copy Markdown

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes
⚠️ None
⚠️Azure CLI Extensions Breaking Change Test
⚠️quantum
rule cmd_name rule_message suggest_message
⚠️ 1015 - SubgroupPropUpdate quantum workspace user sub group quantum workspace user updated property commands from {'quantum workspace user create': {'name': 'quantum workspace user create', 'is_aaz': False, 'parameters': [{'name': '_change_reference', 'options': ['--change-reference']}, {'name': '_acquire_policy_token', 'options': ['--acquire-policy-token']}, {'name': 'resource_group_name', 'options': ['--resource-group', '-g'], 'id_part': 'resource_group', 'has_completer': True}, {'name': 'workspace_name', 'options': ['--workspace-name', '-w']}, {'name': 'assignee', 'options': ['--assignee']}, {'name': 'assignee_object_id', 'options': ['--assignee-object-id']}, {'name': 'assignee_principal_type', 'options': ['--assignee-principal-type'], 'choices': ['ForeignGroup', 'Group', 'ServicePrincipal', 'User']}, {'name': 'role', 'options': ['--role']}]}, 'quantum workspace user delete': {'name': 'quantum workspace user delete', 'is_aaz': False, 'confirmation': True, 'parameters': [{'name': '_change_reference', 'options': ['--change-reference']}, {'name': '_acquire_policy_token', 'options': ['--acquire-policy-token']}, {'name': 'resource_group_name', 'options': ['--resource-group', '-g'], 'id_part': 'resource_group', 'has_completer': True}, {'name': 'workspace_name', 'options': ['--workspace-name', '-w']}, {'name': 'assignee', 'options': ['--assignee']}, {'name': 'assignee_object_id', 'options': ['--assignee-object-id']}, {'name': 'role', 'options': ['--role']}, {'name': 'yes', 'options': ['--yes', '-y']}]}, 'quantum workspace user list': {'name': 'quantum workspace user list', 'is_aaz': False, 'parameters': [{'name': 'resource_group_name', 'options': ['--resource-group', '-g'], 'id_part': 'resource_group', 'has_completer': True}, {'name': 'workspace_name', 'options': ['--workspace-name', '-w']}, {'name': 'include_inherited', 'options': ['--include-inherited'], 'choices': ['false', 'true'], 'nargs': '?', 'default': True}]}} to {'quantum workspace user add': {'name': 'quantum workspace user add', 'is_aaz': False, 'parameters': [{'name': '_change_reference', 'options': ['--change-reference']}, {'name': '_acquire_policy_token', 'options': ['--acquire-policy-token']}, {'name': 'resource_group_name', 'options': ['--resource-group', '-g'], 'id_part': 'resource_group', 'has_completer': True}, {'name': 'workspace_name', 'options': ['--workspace-name', '-w']}, {'name': 'user', 'options': ['--user']}]}, 'quantum workspace user remove': {'name': 'quantum workspace user remove', 'is_aaz': False, 'confirmation': True, 'parameters': [{'name': '_change_reference', 'options': ['--change-reference']}, {'name': '_acquire_policy_token', 'options': ['--acquire-policy-token']}, {'name': 'resource_group_name', 'options': ['--resource-group', '-g'], 'id_part': 'resource_group', 'has_completer': True}, {'name': 'workspace_name', 'options': ['--workspace-name', '-w']}, {'name': 'user', 'options': ['--user']}, {'name': 'yes', 'options': ['--yes', '-y']}]}, 'quantum workspace user list': {'name': 'quantum workspace user list', 'is_aaz': False, 'parameters': [{'name': 'resource_group_name', 'options': ['--resource-group', '-g'], 'id_part': 'resource_group', 'has_completer': True}, {'name': 'workspace_name', 'options': ['--workspace-name', '-w']}, {'name': 'include_inherited', 'options': ['--include-inherited'], 'choices': ['false', 'true'], 'nargs': '?', 'default': True}]}}

Continuation of the work in #10226.
Replaces az quantum workspace user create/delete with add/remove, and makes these commands support only Users and not other principal types.


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az quantum workspace user add

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Konstantin and others added 28 commits August 12, 2026 11:30
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…-Update-user-create-delete

# Conflicts:
#	src/quantum/azext_quantum/_params.py
…-add-remove

# Conflicts:
#	src/quantum/HISTORY.rst
#	src/quantum/azext_quantum/_help.py
#	src/quantum/azext_quantum/_params.py
#	src/quantum/azext_quantum/commands.py
#	src/quantum/azext_quantum/operations/workspace.py
#	src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py
#	src/quantum/setup.py
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Pavel Braginskiy (@pavelbraginskiy),
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@pavelbraginskiy Pavel Braginskiy (pavelbraginskiy) changed the title V pavelbra/53910 user add remove Quantum: Update user create/delete operation by v-pavelbra Aug 31, 2026
@pavelbraginskiy Pavel Braginskiy (pavelbraginskiy) changed the title Quantum: Update user create/delete operation by v-pavelbra Quantum: Update user create/delete operation Aug 31, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Aug 31, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Pavel Braginskiy (@pavelbraginskiy)! We will review the pull request and get back to you soon.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@pavelbraginskiy

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Akvelon Inc"

@pavelbraginskiy
Pavel Braginskiy (pavelbraginskiy) marked this pull request as ready for review August 31, 2026 20:58
Copilot AI lite review requested due to automatic review settings August 31, 2026 20:58
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Quantum extension’s workspace user access commands by renaming az quantum workspace user create/delete to add/remove and tightening the implementation/UX around user-only access management, along with the accompanying version bump, help text, and tests.

Changes:

  • Renamed CLI commands quantum workspace user create/delete to add/remove and updated argument surface to --user.
  • Updated workspace user role-assignment logic to always grant/remove the built-in “Quantum Workspace Data Contributor” role for users.
  • Updated help + tests and bumped extension version/history for the new release.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/quantum/setup.py Bumps extension version to 1.0.0b25.
src/quantum/HISTORY.rst Adds release note for the rename + user-only behavior.
src/quantum/azext_quantum/operations/workspace.py Implements new add_user/remove_user behavior and user resolution.
src/quantum/azext_quantum/commands.py Rewires command table from create/delete to add/remove.
src/quantum/azext_quantum/_params.py Replaces assignee/role params with --user for workspace user commands.
src/quantum/azext_quantum/_help.py Updates help entries and examples to add/remove and --user.
src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py Updates live scenario test and adds unit coverage for new user-access functions.
Suppressed comments (1)

src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py:906

  • If _resolve_user_id is updated to accept object IDs without a Graph call, this unit test should stop asserting that Graph is used for GUID inputs and add a dedicated assertion that GUIDs pass through without invoking graph_client_factory.
    def test_resolve_user_id_uses_graph_user_endpoint(self):
        identifiers = ("user@contoso.com", "00000000-0000-0000-0000-000000000000")
        for identifier in identifiers:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/quantum/azext_quantum/operations/workspace.py Outdated
Comment thread src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py Outdated
@azure-client-tools-agent

Copy link
Copy Markdown

Automated sensitive-information remediation ran on this pull request.

  • Detected categories: email address
  • Replaced with typed [REDACTED:category] placeholders in: no PR metadata fields
  • Comment/review owners notified because Azure Client Tools Agent cannot edit another user's text: copilot-pull-request-reviewer[bot]

Azure Client Tools Agent does not modify source files. The PR creator must remove or replace each suspected value at the linked line:

  • No changed-file findings

If a credential was exposed, rotate or revoke it immediately. Detected values are never copied into this comment.

✅ Confirm the finding · ❌ Dispute the finding

GitHub only supports a fixed reaction set, so 👍 represents ✅ and 👎 represents ❌. The bot-created reactions are only poll choices.

@pavelbraginskiy
Pavel Braginskiy (pavelbraginskiy) marked this pull request as draft August 31, 2026 21:22
# Built-in "Quantum Workspace Owner" role.
QUANTUM_WORKSPACE_OWNER_ROLE_ID = "30b3bcf2-670a-4bdc-8669-7e0ae0c0dfda"

EMAIL_PATTERN = re.compile(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Email regex seems rejects valid sign-in names — B2B guest UPNs (user_contoso.com#EXT#@fabrikam.onmicrosoft.com) and apostrophes (o'brien@contoso.com). Since the only real goal is rejecting object IDs, can we relax to a permissive [^@\s]+@[^@\s]+.[^@\s]+ ? and drop the redundant ^/$ anchors if already using fullmatch.

assignee_type = CLIArgumentType(options_list=['--assignee'], help='Represents a user, group, or service principal. Supported formats: object id, user sign-in name, or service principal name.')
assignee_object_id_type = CLIArgumentType(options_list=['--assignee-object-id'], help="Use this parameter instead of '--assignee' to bypass Graph API invocation in case of insufficient privileges. This parameter only works with object ids for users, groups, service principals, and managed identities. For managed identities use the principal id. For service principals, use the object id and not the app id.")
role_type = CLIArgumentType(options_list=['--role'], help="Role name or id. For 'create', the role granted to the user; for 'delete', the role assignment to remove. Defaults to the 'Quantum Workspace Data Contributor' role.")
assignee_principal_type_type = CLIArgumentType(options_list=['--assignee-principal-type'], arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'ForeignGroup']), help="Use with '--assignee-object-id' to avoid errors caused by propagation latency in Microsoft Graph.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remove stale linter exclusion (linter_exclusions.yml in repo's root) - still has a quantum workspace user create / assignee_principal_type entry for a command and parameter that no longer exist

from azure.cli.command_modules.role import graph_client_factory

_validate_email_arg(email)
return graph_client_factory(cmd.cli_ctx).user_get(email)["id"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we return friendly error to the user if Graph returns 404 here?
raise ResourceNotFoundError(f"No user with the email address '{email}' was found in the directory.") from ex


with self.argument_context('quantum workspace user create') as c:
c.argument('assignee_principal_type', assignee_principal_type_type)
c.argument('email', email_type)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make email argument required for user add and user remove commands?

@azure-client-tools-agent

Copy link
Copy Markdown

Automated sensitive-information remediation ran on this pull request.

Azure Client Tools Agent does not modify source files. The PR creator must remove or replace each suspected value at the linked line:

  • No changed-file findings

If a credential was exposed, rotate or revoke it immediately. Detected values are never copied into this comment.

✅ Confirm the finding · ❌ Dispute the finding

GitHub only supports a fixed reaction set, so 👍 represents ✅ and 👎 represents ❌. The bot-created reactions are only poll choices.

helps['quantum workspace user remove'] = """
type: command
short-summary: Remove a user, group, or service principal's access to an Azure Quantum workspace.
short-summary: Remove a user's access to an Azure Quantum workspace.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also mention what exactly role we are removing in long-summary similar to what we have in user add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-codegen-extensibility-squad Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. Quantum az quantum

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants