Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ImageCopy] Fixing accessSAS according to latest azure-cli with fallback #8437

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajgupta42
Copy link

@ajgupta42 ajgupta42 commented Jan 24, 2025


Changes related to breaking changes in azure-cli v2.68.0
Azure/azure-cli#30430

Changes for API 2024-12-01-preview

apiVersion has been changed in azCli, keeping it working for older versions of azure-cli too as fallback

Related command

az image copy --source-resource-group production --target-location eastus2 --source-type image --source-object-name ubuntu-2004-20250124 --target-resource-group production --target-name test-image-eus2 --tags current=true

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.

Copy link

azure-client-tools-bot-prd bot commented Jan 24, 2025

️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

Copy link

Hi @ajgupta42,
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.

Copy link

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>

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 24, 2025

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

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot labels Jan 24, 2025
Copy link

github-actions bot commented Jan 24, 2025

@ajgupta42 ajgupta42 force-pushed the image-copy-ext-accessSAS branch from 0695d30 to 80eb2b4 Compare January 24, 2025 10:41
@ajgupta42
Copy link
Author

@microsoft-github-policy-service agree

@ajgupta42
Copy link
Author

Patch for:

az image copy --source-resource-group production --target-location eastus2 --source-type image --source-object-name ubuntu-2004-20250124 --target-resource-group production --target-name test-image-eus2 --tags current=true


WARNING: Getting OS disk ID of the source VM/image
WARNING: Creating source snapshot
WARNING: Getting sas url for the source snapshot with timeout: 3600 seconds
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'accessSas'
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.azure/cliextensions/image-copy-extension/azext_imagecopy/custom.py", line 145, in imagecopy
    source_os_disk_snapshot_url = json_output['accessSas']
                                  ~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'accessSas'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

@ajgupta42
Copy link
Author

[anuj@Anuj-Gupta] [~/azure-cli-extensions] (image-copy-ext-accessSAS)
> python scripts/ci/test_index.py -q
----------------------------------------------------------------------
Ran 9 tests in 0.126s

OK (skipped=2)

@ajgupta42
Copy link
Author

Tested it locally

az image copy --source-resource-group production --target-location eastus2 --source-type image --source-object-name ubuntu-2004-20250124 --target-resource-group production --target-name test-image-eus2 --tags current=true

Getting OS disk ID of the source VM/image
Creating source snapshot
Getting sas url for the source snapshot with timeout: 3600 seconds
Target location count: 1
eastus2 - Creating target storage account (can be slow sometimes)
eastus2 - Creating container in the target storage account
eastus2 - Copying blob to target storage account
eastus2 - Copy progress: 0%
eastus2 - Copy progress: 1%
eastus2 - Copy progress: 2%
.
.
.
eastus2 - Copy progress: 100%
eastus2 - Copy time: 0:23:47.662489
eastus2 - Creating snapshot in target region from the copied blob
eastus2 - Creating final image
Image copy finished

@ajgupta42
Copy link
Author

/azp run

Copy link

Commenter does not have sufficient privileges for PR 8437 in repo Azure/azure-cli-extensions

@ajgupta42 ajgupta42 changed the title Fixing accessSAS according to latest azure-cli with fallback [ImageCopy] Fixing accessSAS according to latest azure-cli with fallback Jan 27, 2025
@ajgupta42
Copy link
Author

@zhoxing-ms @yanzhudd @yonzhan Please review(in case it was missed)

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 27, 2025

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@ajgupta42
Copy link
Author

Thanks @yonzhan for running the az pipelines
Seems like it's a clear run 👍

@ajgupta42
Copy link
Author

@zhoxing-ms @yanzhudd @yonzhan Please approve

@ajgupta42
Copy link
Author

Bump for approval, in case it is missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Compute customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants