Skip to content

Add az site key commands to manage Site Keys for Azure Edge sites#9794

Open
aupmanyu-msft-work wants to merge 11 commits into
Azure:mainfrom
aupmanyu-msft-work:feature-sitekey-cli
Open

Add az site key commands to manage Site Keys for Azure Edge sites#9794
aupmanyu-msft-work wants to merge 11 commits into
Azure:mainfrom
aupmanyu-msft-work:feature-sitekey-cli

Conversation

@aupmanyu-msft-work
Copy link
Copy Markdown
Member


Add CLI commands to manage Site Keys (siteKeys) for Azure Edge sites, scoped to resource group.

API version: 2026-04-01-preview (Microsoft.Edge/siteKeys)

Related command

az site key create - Create a site key linked to a site
az site key show - Get details of a specific site key
az site key list - List all site keys in a resource group
az site key delete - Delete a site key
az site key download - Download the token for a site key to a file

General Guidelines

  • Have you run azdev style 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:

aupmanyu-microsoft and others added 2 commits April 17, 2026 11:37
…identity

- set_const signature is (name, value, type) not (name, type, value)
- API requires identity.type=SystemAssigned on siteKey creation
- Use hidden arg for siteResourceId populated in pre_operations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…key commands

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 17, 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

…iteKey

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yonzhan yonzhan requested a review from necusjz April 17, 2026 09:33
aupmanyu-microsoft and others added 4 commits May 8, 2026 10:23
- Create _error_handler.py with handle_sitekey_error() for known API errors
- Integrate error handler into all 5 commands (create, show, delete, download, list)
- Polished alerts follow Azure customer-facing style: clear title, numbered steps, error code
- Handles: token expiry, duplicate key, site not found, key not found errors
- Unknown errors pass through unchanged

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Format errors as 'Option N / Title / Recommendation' structure
- Each option has labeled Title and indented numbered steps
- Error code at the end
- Supports multiple options per alert for future extensibility

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add is_preview=True to 'site key' command group registration
- Update HISTORY.rst to indicate [Preview] status and API version 2026-04-01-preview

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
aupmanyu-microsoft and others added 2 commits May 27, 2026 14:13
…move docs

- Move _error_handler.py out of aaz/latest/ tree to azext_site/ root
  (prevents clobbering on aaz-dev-tools regeneration)
- Update all 5 command imports to reference new location
- Fix _download.py docstring: .txt -> .SiteKey
- Test now writes token to temp dir and cleans up after
- Remove docs/ folder (contained only sitekey draft docs with drift)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add post-regen instructions comment to _error_handler.py
- Wrap token file cleanup in try/finally so file is removed even on test failure

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aupmanyu-msft-work aupmanyu-msft-work marked this pull request as ready for review May 27, 2026 09:22
Copilot AI review requested due to automatic review settings May 27, 2026 09:22
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new preview az site key command group (create/show/list/delete/download) and bumps the extension version to 1.0.0b2, including scenario tests + recordings for the new functionality.

Changes:

  • Bump extension version and update release notes for the new site key command group.
  • Add generated AAZ command implementations for az site key * plus CLI help entries.
  • Add a new scenario test and recordings covering site key CRUD + download.

Reviewed changes

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

Show a summary per file
File Description
src/site/setup.py Version bump to 1.0.0b2.
src/site/HISTORY.rst Release notes for the new preview command group.
src/site/azext_site/_help.py Adds help/usage text for site key commands.
src/site/azext_site/_error_handler.py Adds custom error handling for common site key API failures.
src/site/azext_site/tests/latest/test_site.py Adds scenario test for az site key CRUD + download.
src/site/azext_site/tests/latest/recordings/test_edge_site_key_crud.yaml Adds recorded HTTP interactions for playback tests.
src/site/azext_site/aaz/latest/site/key/__cmd_group.py Registers the site key command group (preview).
src/site/azext_site/aaz/latest/site/key/init.py Exposes the new site key commands.
src/site/azext_site/aaz/latest/site/key/_create.py Implements az site key create.
src/site/azext_site/aaz/latest/site/key/_delete.py Implements az site key delete.
src/site/azext_site/aaz/latest/site/key/_list.py Implements az site key list with paging.
src/site/azext_site/aaz/latest/site/key/_show.py Implements az site key show.
src/site/azext_site/aaz/latest/site/key/_download.py Implements az site key download and writes token to a local file.

Comment on lines +180 to +191
token_file = os.path.join(tempfile.gettempdir(), "test-token.SiteKey")
try:
self.cmd(
"az site key download --name TestSiteKey --resource-group {{rg}} --file {f}".format(f=token_file),
checks=[
self.exists("filePath"),
self.check("message", "Token saved successfully"),
]
)
finally:
if os.path.exists(token_file):
os.remove(token_file)
self.exists("filePath"),
self.check("message", "Token saved successfully"),
]
)
Comment on lines +108 to +112
file_path = os.path.abspath(file_path)
with open(file_path, "w") as f:
f.write(token)
logger.warning("Token saved to %s", file_path)
return {"filePath": file_path, "message": "Token saved successfully"}
Comment on lines +108 to +110
file_path = os.path.abspath(file_path)
with open(file_path, "w") as f:
f.write(token)
aupmanyu-microsoft and others added 2 commits May 27, 2026 14:58
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

5 participants