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

az image copy from one region to another does not work #25431

Closed
evolkovgit opened this issue Feb 11, 2023 · 13 comments
Closed

az image copy from one region to another does not work #25431

evolkovgit opened this issue Feb 11, 2023 · 13 comments
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team Compute az vm/vmss/image/disk/snapshot customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone

Comments

@evolkovgit
Copy link

evolkovgit commented Feb 11, 2023

The below is a command and full output. It cannot be simpler. I also tried it long time ago with "az feedback" but did not see any response. I simply want to copy my custom image from one region (eastus) to another (southcentralus). I understand that the system is looking for "'MyHPCImage-7_os_disk_snapshot" and I do not have it. But why should I have it? I have an existing image "MyHPCImage-7" which I successfully use in my deployments. This should be enough. I want to add that the corresponding question by somebody else on stackoverflow was never answered: https://stackoverflow.com/questions/45720966/how-to-copy-an-azure-image-from-one-region-to-another-region

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

I did that long time ago, never got a response

Related command
az image copy --source-resource-group "ResGroupForMetaBatchAccount" --source-object-name "MyHPCImage-7" --target-location "southcentralus" --target-resource-group "ResGroupForMetaBatchAccount-southcentralus" --cleanup

Describe the bug
It returns ERROR, the image is not copied

To Reproduce
Run the above command

evgeniy@Azure:~$ az image copy --source-resource-group "ResGroupForMetaBatchAccount" --source-object-name "MyHPCImage-7" --target-location  "southcentralus" --target-resource-group "ResGroupForMetaBatchAccount-southcentralus" --cleanup
Getting OS disk ID of the source VM/image
Creating source snapshot
command failed: ['/usr/bin/python3.9', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'MyHPCImage-7_os_disk_snapshot', '--location', 'eastus', '--resource-group', 'ResGroupForMetaBatchAccount', '--source', '/subscriptions/5
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
To open a new issue, please run `az feedback`

Additional context
It is a linux image . Please help to copy image to another region.

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. Compute az vm/vmss/image/disk/snapshot labels Feb 11, 2023
@ghost ghost added this to the Backlog milestone Feb 11, 2023
@ghost ghost assigned zhoxing-ms Feb 11, 2023
@ghost ghost added the Auto-Assign Auto assign by bot label Feb 11, 2023
@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 11, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Feb 11, 2023

@zhoxing-ms for awareness

@wu5bocheng
Copy link
Contributor

@evolkovgit Thank you for bringing this issue to our attention. I apologize for the inconvenience caused by the error in the az image copy process.

From my investigation, it appears that the error is caused by the missing "'MyHPCImage-7_os_disk_snapshot" file, which is created during the process of creating an image from a generalized VM. This file is necessary for the image service to store the image information and is also part of the billing process.

I understand that you only have the mirror file in your resource group "MyHPCImage-7" which only stores information such as the path and version of the mirror file. In the event that the snapshot file is deleted, the mirror will not be usable or movable.

I appreciate your feedback and we will consider reminding users of the consequences of the operation and requesting reconfirmation when they delete the snapshot file of the associated mirror.

If you have any follow-up questions, please do not hesitate to contact me.

@evolkovgit
Copy link
Author

Hi @wu5bocheng . Sorry, I am not satisfied with your answer. As I wrote in the initial BUG description, it was clear to me that the missing "'MyHPCImage-7_os_disk_snapshot" was the reason. I created the image "MyHPCImage-7" from running VM via Azure portal feature "Capture" (https://learn.microsoft.com/en-us/azure/virtual-machines/capture-image-portal) and the snapshot was NOT created automatically during the process. "MyHPCImage-7" is still perfectly working image. I successfully use it in deployments without having the "snapshot" . It works. I repeat, it is not a "mirror" as you wrote. Also I never manually deleted any snapshot. There is nothing about the "snapshot" in the above link. Also there is no portal GUI to create a "snapshot" from an image. You wrote that the "snapshot" is created during the process of creating an image from a generalized VM. It is not true. It is never created for me. Which options I should enable so the "snapshot" IS CREATED while using the "capture" feature? So it is a bug.

@wu5bocheng
Copy link
Contributor

Hi, @evolkovgit. I apologize for mislocating your issue earlier, I read it carefully and tried to reproduce your problem. I think you deleted the system disk of the VM where the image was created (or chose to delete the VM while creating the image). Your MyHPCImage-7 is based on the VM vmimage capture, but the system disk vmimage_disk1_7cdff216f6ab46b8a41ccd5ada16c695 that was deleted after the capture. Since the system disk could not be found, the image could not be automatically created by image-copy-extension automatically creates MyHPCImage-7_os_disk_snapshot and moves it, so it reports an error that MyHPCImage-7_os_disk_snapshot cannot be found.

If it is the case of your problem, here is a temporary solution that you can try to resolve the issue:

  1. First, create a new virtual machine vm_temp by the image MyHPCImage-7.
  2. Then, create a new image image_new for the virtual machine vm_temp.
  3. Finally, use the new image image_new to perform a copy operation.

If I have mislocated your issue, could you please provide me with the output of
az resource list --resource-group ResGroupForMetaBatchAccount (if the output is too long to paste into the comments section, please store the output as a json file and mailto: v-bochengwu@microsoft.com) so that I can better help you solve the problem.

I hope this solution helps you. If you have any further questions or concerns, please do not hesitate to contact me.

@evolkovgit
Copy link
Author

Hi @wu5bocheng

Thank you for your response. You wrote:
>I think you... chose to delete the VM while creating the image
Correct, in the "capture" feature, I used the option (check-box) to delete the VM automatically after creating the image. The reason I do it because the generalized VM is useless after the "generalization" process, since it is somehow removes the Linux "azureuser" credentials and I cannot login there any longer.

I will use your temporary solution (without deleting the VM during the "capture" ) and it will probably help.

I still think that it is bug in Azure CLI. The "az image copy" python code should simply create missing "'MyHPCImage-7_os_disk_snapshot" automatically if it needs it and delete it afterwards (by --clean) option .

Again, thank you. I will use your temporary solution.

Eugene

@evolkovgit
Copy link
Author

Hi @wu5bocheng

It still did not work (probably because my VM is Linux and you are experimenting with Windows VMs)

  1. I created VM called "vmimage" using "MyHPCImage-7" image. The VM was OK, I am able to SSH there

  2. I captured the image "MyHPCImage-8" from the VM "vmimage". I had the option "Automatically delete this virtual machine after creating the image" unchecked.

  3. So now I have both VM "vmimage" and "MyHPCImage-8" existing. I checked in portal "snapshots" if there is a snapshot for "MyHPCImage-8" : No, it was not there.

  4. Anyway, I issued the command in Azure CLI:
    az image copy --source-resource-group "ResGroupForMetaBatchAccount" --source-object-name "MyHPCImage-8" --target-location "southcentralus" --target-resource-group "ResGroupForMetaBatchAccount-southcentralus" --cleanup
    I got the result:
    Don't specify an existing resource group in --temporary-resource-group-name when --cleanup is set

The above is wrong (bug) because I did not specify any --temporary-resource-group-name
5. Now (as you asked me) I am issuing :
az resource list --resource-group ResGroupForMetaBatchAccount
The result is long JSON text, I will send it to you via email (as you asked), but do not look for the snapshot in the list: it is not there.

Something to add:

a. The "generalized" "vmimage" Linux VM is useless now, because I cannot SSH-login there after it was "generalized" during the "capture" process. So , since it still does not work, I will delete it. The captured image "MyHPCImage-8" is still OK, though there is still no corresponding snapshot. Since it is the same as the previous one "MyHPCImage-7" I will delete it as well after some attempts.
b. I tried to "move" the "MyHPCImage-8" image via Azure Web Portal GUI , it did not work either

regards,
Eugene

@wu5bocheng
Copy link
Contributor

wu5bocheng commented Feb 14, 2023

Hi @evolkovgit. Sorry, I just tried again, but I couldn't reproduce your problem, so more assistance may be needed from you. Please run 'az image copy --source-resource-group "ResGroupForMetaBatchAccount" --source-object-name "MyHPCImage-8" -- target-location "southcentralus" --target-resource-group "ResGroupForMetaBatchAccount-southcentralus" --cleanup --debug' and send the output to me.
Please run this command with image created and vm reserved.

@evolkovgit
Copy link
Author

evolkovgit commented Feb 14, 2023 via email

@evolkovgit
Copy link
Author

OK, I decided not to go to sleep :-) and do it now
Please let me know ASAP: I want to delete useless VM and image (not to pay for resources I do not need)

  1. I created VM called "vmimage" using "MyHPCImage-7" image. The VM was OK, I am able to SSH there
  2. I captured the image "MyHPCImage-8" from the VM "vmimage". I had the option "Automatically delete this virtual machine after creating the image" unchecked.
  3. So now I have both VM "vmimage" and "MyHPCImage-8" existing.
  4. I am issuing the az image copy command with the --debug option. Below is full output
Requesting a Cloud Shell.Succeeded. 
Connecting terminal...

evgeniy@Azure:~$ az image copy --source-resource-group "ResGroupForMetaBatchAccount" --source-object-name "MyHPCImage-8" --target-location  "southcentralus" --target-resource-group "ResGroupForMetaBatchAccount-southcentralus" --cleanup --debug
cli.knack.cli: Command arguments: ['image', 'copy', '--source-resource-group', 'ResGroupForMetaBatchAccount', '--source-object-name', 'MyHPCImage-8', '--target-location', 'southcentralus', '--target-resource-group', 'ResGroupForMetaBatchAccount-southcentralus', '--cleanup', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fe398dae160>, <function OutputProducer.on_global_arguments at 0x7fe398cccb80>, <function CLIQuery.on_global_arguments at 0x7fe398c5d160>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'image': ['azure.cli.command_modules.vm', 'azext_imagecopy']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: vm                        0.264        57       281
cli.azure.cli.core: Total (1)                 0.264        57       281
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: image-copy-extension      0.008         1         1  /home/evgeniy/.azure/cliextensions/image-copy-extension
cli.azure.cli.core: ai-examples               0.123         1         1  /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: Total (2)                 0.130         2         2  
cli.azure.cli.core: Loaded 58 groups, 283 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : image copy
cli.azure.cli.core: Command table: image copy
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fe397f0bc10>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/evgeniy/.azure/commands/2023-02-14.08-14-13.image_copy.134.log'.
az_command_data_logger: command args: image copy --source-resource-group {} --source-object-name {} --target-location {} --target-resource-group {} --cleanup --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fe397eb3820>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fe397e7f0d0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7fe397e7f280>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fe398cccc10>, <function CLIQuery.handle_query_parameter at 0x7fe398c5d1f0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7fe397e7f1f0>]
az_command_data_logger: extension name: image-copy-extension
az_command_data_logger: extension version: 0.2.9
cli.azext_imagecopy.cli_utils: command: ['/usr/bin/python3.9', '-m', 'azure.cli', 'group', 'exists', '-n', 'image-copy-rg', '--output', 'tsv'] ended with output: true

cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/evgeniy/.azure/cliextensions/image-copy-extension/azext_imagecopy/custom.py", line 31, in imagecopy
    raise CLIError('Don\'t specify an existing resource group in --temporary-resource-group-name '
knack.util.CLIError: Don't specify an existing resource group in --temporary-resource-group-name when --cleanup is set

cli.azure.cli.core.azclierror: Don't specify an existing resource group in --temporary-resource-group-name when --cleanup is set
az_command_data_logger: Don't specify an existing resource group in --temporary-resource-group-name when --cleanup is set
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fe397f0be50>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.531 seconds (init: 0.126, invoke: 1.405)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3568 in cache
telemetry.check: Negative: The /home/evgeniy/.azure/telemetry.txt was modified at 2023-02-14 08:12:10.689799, which in less than 600.000000 s
evgeniy@Azure:~$ 

@wu5bocheng
Copy link
Contributor

Thank you for bringing your issue to our attention. I apologize for any inconvenience caused. As the problem you are experiencing is specific and is challenging to reproduce. I appreciate your help in resolving this issue. I regret not suggesting "-- debug" option earlier. I will ensure that our team is more proactive in suggesting this option in the future.

As for your question about the "move" image via Azure Portal GUI, please note that the "az_image_copy" method is still under preview, and this feature is not yet supported by the portal. We appreciate your patience and understanding as we work to resolve this issue.

Thank you for your continued support. You can delete all the new formed items such as vmimage and MyHPCImage-8 except for raw image MyHPCImage-7, and your debug output should help us solve the problem.

@wu5bocheng
Copy link
Contributor

Hello, @evolkovgit. Thank you for bringing to our attention the new issue you are experiencing with the --temporary-resource-group-name parameter in the image copy command. We understand that this error is caused by a conflict in the name of the temporary resource group, which results from the resource group image-copy-rg not being deleted during your previous image copy command execution.

To solve this problem, we recommend two possible workarounds. First, if the image-copy-rg resource group is not being used for any business operations, it is recommended that you delete it and run the image copy command again. Second, if the image-copy-rg resource group is being used and cannot be deleted, you can add the parameter --temporary-resource-group-name {unused_group_name} to the image copy command.

We would also like to address your previous feedback about the inability to move images through the portal. Please note that the image copy method is maintained by an extension and does not guarantee a stable development and operation rhythm, and therefore cannot be supported in the portal.

Also, make sure you fix the previous bug where the system disk was deleted before running copy.

  1. First, create a new virtual machine vm_temp by the image MyHPCImage-7.
  2. Then, create a new image image_new for the virtual machine vm_temp.
  3. Finally, use the new image image_new to perform a copy operation.

We recommend that when you need to move an image in the future, please move the image first and then delete the original VM.

Thank you for your understanding, and please let us know if you have any further questions or concerns.

@evolkovgit
Copy link
Author

evolkovgit commented Feb 15, 2023

Hi @wu5bocheng ,

I was finally able to copy my image to another region using the workaround you suggested.
I appreciate your help and I am impressed how fast you answer. Such care makes all the difference. Thank you very much.
You can close the issue if you want, though I think you understand: there is much to be done to improve the "az_image_copy" command.

Thank you again,
Eugene

@wu5bocheng
Copy link
Contributor

Dear Eugene,
Thank you for reaching out to us and providing feedback on the extension module. We are delighted to hear that the workaround suggestion was helpful and that you were able to copy your image to another region.
We appreciate your kind words about the prompt response you received from us. Our team is committed to enhancing the user experience and maintaining the stability of the extension module. We value your support and feedback.
As per your request, we will close the issue. If you encounter any further issues or have additional feedback, please do not hesitate to submit a new issue or reopen the closed one.
Thank you again for your feedback and support.
Best regards,
Bocheng Wu

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 Azure CLI Team The command of the issue is owned by Azure CLI team Compute az vm/vmss/image/disk/snapshot customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants