Quantum: Update user create/delete operation - #10282
Quantum: Update user create/delete operation#10282Pavel Braginskiy (pavelbraginskiy) wants to merge 30 commits into
Conversation
…ser list` command
…help documentation
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
…kaverkiev/azure-cli-extensions into v-kaverkiev/workspace-user-list
…-Update-user-create-delete
…D; update related tests
…-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
|
Hi Pavel Braginskiy (@pavelbraginskiy), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution Pavel Braginskiy (@pavelbraginskiy)! We will review the pull request and get back to you soon. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
@microsoft-github-policy-service agree company="Akvelon Inc" |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
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/deletetoadd/removeand 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.
|
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:
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. |
| # 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,}$") |
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
should we make email argument required for user add and user remove commands?
|
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:
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. |
There was a problem hiding this comment.
let's also mention what exactly role we are removing in long-summary similar to what we have in user add
🤖 PR Validation —⚠️ Review suggested
Continuation of the work in #10226.
Replaces
az quantum workspace user create/deletewithadd/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 addGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)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.jsonautomatically.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.