Skip to content

Added sync commands#9824

Open
guptahars wants to merge 1 commit intoAzure:mainfrom
guptahars:main
Open

Added sync commands#9824
guptahars wants to merge 1 commit intoAzure:mainfrom
guptahars:main

Conversation

@guptahars
Copy link
Copy Markdown
Contributor


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

Related command

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 wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

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.

Copilot AI review requested due to automatic review settings April 23, 2026 19:20
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented Apr 23, 2026

⚠️Azure CLI Extensions Breaking Change Test
⚠️workload-orchestration
rule cmd_name rule_message suggest_message
⚠️ 1001 - CmdAdd workload-orchestration sync cmd workload-orchestration sync added

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @guptahars,
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 setup.py as well.

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 23, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions
Copy link
Copy Markdown
Contributor

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@github-actions
Copy link
Copy Markdown
Contributor

Hi @guptahars

Release Suggestions

Module: workload-orchestration

  • Please log updates into to src/workload-orchestration/HISTORY.rst
  • Update VERSION to 5.2.0 in src/workload-orchestration/setup.py

Notes

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new az workload-orchestration sync command intended to re-sync workload-orchestration targets (and reinstall deployed solution versions) for a given custom location, including special handling for staged solutions.

Changes:

  • Introduces workload-orchestration sync AAZ command that queries targets via Azure Resource Graph and orchestrates per-target sync.
  • Adds helper implementation to PUT targets, poll provisioning, query installed solution versions, and (re)install solutions (including staged review/publish/install flow).
  • Exposes the new command via the workload_orchestration package __init__.py.

Reviewed changes

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

File Description
src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/_sync.py New workload-orchestration sync command, ARG target discovery, interactive selection, and summary output.
src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/_resync_target_helper.py Parallel per-target sync orchestration, ARG solution-version discovery, staged-solution config/review/publish/install, retry + polling logic.
src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/__init__.py Exports the newly added sync command module.

Comment on lines +254 to +261
def url_parameters(self):
target_id = self._target["id"]
parts = target_id.split("/")
return {
**self.serialize_url_param("subscriptionId", parts[2], required=True),
**self.serialize_url_param("resourceGroupName", parts[4], required=True),
**self.serialize_url_param("targetName", parts[8], required=True),
}
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

This parses the target ARM ID by fixed segment indices (parts[2], parts[4], parts[8]). If the ID format is unexpected, this will raise IndexError and surface a confusing stack trace. Consider using a safer parse (e.g., validate the split length and keys, or use a resource-id parser helper) and raise a CLIInternalError/InvalidArgumentValueError with the problematic ID.

Copilot uses AI. Check for mistakes.
Comment on lines +340 to +342
sv_parts = self._solution_version_id.split("/")
solution_unique_id = sv_parts[10]

Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

This assumes the solution version ARM ID always has the expected /solutions/{uniqueId}/versions/{version} shape and indexes sv_parts[10]. If the ID format changes or differs, this will throw IndexError. Consider validating the split result (or parsing as a resource ID) and emitting a clearer error that includes the offending solutionVersionId.

Suggested change
sv_parts = self._solution_version_id.split("/")
solution_unique_id = sv_parts[10]
sv_parts = [part for part in self._solution_version_id.split("/") if part]
try:
solutions_index = sv_parts.index("solutions")
versions_index = sv_parts.index("versions", solutions_index + 1)
except ValueError:
raise Exception(
f"Invalid solutionVersionId format. Expected ARM ID containing "
f"'/solutions/{{uniqueId}}/versions/{{version}}', got: {self._solution_version_id}"
)
if versions_index != solutions_index + 2:
raise Exception(
f"Invalid solutionVersionId format. Expected ARM ID containing "
f"'/solutions/{{uniqueId}}/versions/{{version}}', got: {self._solution_version_id}"
)
solution_unique_id = sv_parts[solutions_index + 1]

Copilot uses AI. Check for mistakes.
Comment on lines +200 to +215
def content(self):
custom_location = self.ctx.args.custom_location.to_serialized_data()
body = {
"query": (
"Resources"
" | where type =~ 'Microsoft.Edge/targets'"
f" | where extendedLocation.name =~ '{custom_location}'"
" | where properties.provisioningState =~ 'Succeeded'"
" | project id, name, location, resourceGroup, subscriptionId,"
" extendedLocation, properties, tags"
),
"options": {
"resultFormat": "objectArray"
}
}
return self.serialize_content(body)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The Resource Graph POST body is missing the required "subscriptions" (or "managementGroups") scope. Without it, /providers/Microsoft.ResourceGraph/resources requests typically fail with a 400. Consider adding "subscriptions": [self.ctx.subscription_id] (or a user-provided list) to the body alongside the query/options.

Copilot uses AI. Check for mistakes.
Comment on lines +100 to +107
# Step 2: Determine which targets to sync
_log_step("[Step 2/3] Determining which targets to sync...")
selected_targets = self._targets
from knack.prompting import prompt
user_input = prompt(
"\nEnter the numbers of the targets to sync (e.g. 1,3) or press Enter to sync all: "
)
if user_input.strip():
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

This command always prompts for target selection, which makes it unusable in non-interactive/automation scenarios (CI, scripts, piping). Consider adding a non-interactive selection argument (e.g., --target-ids/--target-names/--all plus optional --yes/--no-prompt) and only prompting when running in an interactive TTY and no explicit selection was provided.

Copilot uses AI. Check for mistakes.
"""

_aaz_info = {
"version": "2025-06-01",
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

_aaz_info is set to version "2025-06-01" while the rest of the extension’s latest commands appear to use "2025-08-01". If this command targets the same API surface as the other latest commands, align the version metadata to avoid confusing version skew (and to match the declared resources/api-versions used by the operations).

Suggested change
"version": "2025-06-01",
"version": "2025-08-01",

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +37
@register_command(
"workload-orchestration sync",
)
class Sync(AAZCommand):
"""Sync workload orchestration resources for a custom location

:example: Sync resources for a custom location
az workload-orchestration sync --custom-location /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/myCustomLocation
"""
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

New command behavior isn’t covered by the extension’s existing ScenarioTest suite. Since this adds a new top-level command, consider adding at least one scenario test (and recording) that validates the ARG query wiring and the per-target sync flow (or a minimal mocked/recorded path), especially once a non-interactive selection flag exists.

Copilot uses AI. Check for mistakes.
Comment on lines +199 to +214
def content(self):
body = {
"query": (
"ExtensibilityResources"
" | where type =~ 'microsoft.edge/targets/solutions/versions'"
f" | where tolower(id) startswith tolower('{self._target_id}')"
" | project id, name, location, resourceGroup, subscriptionId,"
" provisioningState = tostring(properties.provisioningState),"
" state = tostring(properties.state),"
" specification = properties.specification"
),
"options": {
"resultFormat": "objectArray"
}
}
return self.serialize_content(body)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The Resource Graph POST body is missing the required "subscriptions" (or "managementGroups") scope. Add a scope (e.g., "subscriptions": [ctx.subscription_id]) so the query executes against the intended subscription(s).

Copilot uses AI. Check for mistakes.
@yonzhan yonzhan requested a review from necusjz April 23, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants