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

Azure tags are not getting parsed correctly with 'az image copy' command #6628

Closed
rdhanase opened this issue Aug 10, 2023 · 2 comments
Closed
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team Compute 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

@rdhanase
Copy link

Describe the bug

tags were parsed by 'cli.knack.cli' but 'cli.azext_imagecopy.cli_utils' did not receive or is not using them.
and hence we are seeing the the command to create snapshot is missing the tags we supply.
command used -
az image copy --source-object-name ****** --source-resource-group ServerlessDevSetup --target-location westus --target-resource-group IICS_build --source-type image --target-name packercldagnt-serverless-westus-ML_copyTest --target-subscription *********** --tags BUSINESSUNIT=IAS BUSINESSENTITY=INTCLOUD OWNEREMAIL=[email protected] --debug –-verbose –-output json > az_copy_image.json

What you passed in:
DEBUG: cli.knack.cli: Command arguments: ['image', 'copy', '--source-object-name', 'packercldagnt-serverless-westus-MLR4311771-test11', '--source-resource-group', 'ServerlessDevSetup', '--target-location', 'westus', '--target-resource-group', 'IICS_build', '--source-type', 'image', '--target-name', 'packercldagnt-serverless-westus-ML_copyTest', '--target-subscription', '***********', '--tags', 'BUSINESSUNIT=IAS', 'BUSINESSENTITY=INTCLOUD', '[email protected]', '--debug', '--verbose', '--output', 'json']

But the azext_imagecopy command is only declaring one tag for itself:
ERROR: cli.azext_imagecopy.cli_utils: command failed: ['/usr/local/Cellar/azure-cli/2.48.1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions/********/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']

Failure:
ERROR: cli.azext_imagecopy.cli_utils: output: ERROR: (RequestDisallowedByPolicy) Resource 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot' was disallowed by policy. Reasons: 'Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement'. See error details for policy resource IDs.
Code: RequestDisallowedByPolicy
Message: Resource 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot' was disallowed by policy. Reasons: 'Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement'. See error details for policy resource IDs.
Target: packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot

Related command

az image copy --source-object-name ****** --source-resource-group ServerlessDevSetup --target-location westus --target-resource-group IICS_build --source-type image --target-name packercldagnt-serverless-westus-ML_copyTest --target-subscription *********** --tags BUSINESSUNIT=IAS BUSINESSENTITY=INTCLOUD OWNEREMAIL=[email protected] --debug –-verbose –-output json > az_copy_image.json

Errors

ERROR: cli.azext_imagecopy.cli_utils: output: ERROR: (RequestDisallowedByPolicy) Resource 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot' was disallowed by policy. Reasons: 'Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement'. See error details for policy resource IDs.
Code: RequestDisallowedByPolicy
Message: Resource 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot' was disallowed by policy. Reasons: 'Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement'. See error details for policy resource IDs.
Target: packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot

Issue script & Debug output

➜ ~ az image copy --source-object-name packercldagnt-serverless-westus-MLR4311771-test11 --source-resource-group ServerlessDevSetup --target-location westus --target-resource-group IICS_build --source-type image --target-name packercldagnt-serverless-westus-ML_copyTest --target-subscription ************************************ --tags BUSINESSUNIT=IAS BUSINESSENTITY=INTCLOUD OWNEREMAIL=[email protected] --debug --verbose > az_image_copy.log
DEBUG: cli.knack.cli: Command arguments: ['image', 'copy', '--source-object-name', 'packercldagnt-serverless-westus-MLR4311771-test11', '--source-resource-group', 'ServerlessDevSetup', '--target-location', 'westus', '--target-resource-group', 'IICS_build', '--source-type', 'image', '--target-name', 'packercldagnt-serverless-westus-ML_copyTest', '--target-subscription', '', '--tags', 'BUSINESSUNIT=IAS', 'BUSINESSENTITY=INTCLOUD', 'OWNEREMAIL=[email protected]', '--debug', '--verbose']
DEBUG: cli.knack.cli: init debug log:
Cannot enable color.
DEBUG: cli.knack.cli: Event: Cli.PreExecute []
DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x10aea9ea0>, <function OutputProducer.on_global_arguments at 0x10af52f80>, <function CLIQuery.on_global_arguments at 0x10af8c430>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'image': ['azure.cli.command_modules.vm', 'azext_imagecopy']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands
DEBUG: cli.azure.cli.core: vm 0.243 58 264
DEBUG: cli.azure.cli.core: Total (1) 0.243 58 264
DEBUG: cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
DEBUG: cli.azure.cli.core: Loading extensions:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands Directory
DEBUG: cli.azure.cli.core: image-copy-extension 0.002 1 1 /Users/rdhanase/.azure/cliextensions/image-copy-extension
DEBUG: cli.azure.cli.core: Total (1) 0.002 1 1
DEBUG: cli.azure.cli.core: Loaded 58 groups, 265 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command : image copy
DEBUG: cli.azure.cli.core: Command table: image copy
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x10bc06ef0>]
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/rdhanase/.azure/commands/2023-08-10.11-56-14.image_copy.52581.log'.
INFO: az_command_data_logger: command args: image copy --source-object-name {} --source-resource-group {} --target-location {} --target-resource-group {} --source-type {} --target-name {} --target-subscription {} --tags {} {} {} --debug --verbose
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x10bc1f880>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x10bc59630>, <function register_cache_arguments..add_cache_arguments at 0x10bc59750>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x10af53010>, <function CLIQuery.handle_query_parameter at 0x10af8c4c0>, <function register_ids_argument..parse_ids_arguments at 0x10bc596c0>]
INFO: az_command_data_logger: extension name: image-copy-extension
INFO: az_command_data_logger: extension version: 0.2.13
DEBUG: cli.azext_imagecopy.custom: subscription id - ************************************
WARNING: cli.azext_imagecopy.custom: Getting OS disk ID of the source VM/image
DEBUG: cli.azext_imagecopy.cli_utils: command: ['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'image', 'show', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11', '--resource-group', 'ServerlessDevSetup', '--output', 'json'] ended with output: {
"extendedLocation": null,
"hyperVGeneration": "V1",
"id": "/subscriptions/
/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/images/packercldagnt-serverless-westus-MLR4311771-test11",
"location": "westus",
"name": "packercldagnt-serverless-westus-MLR4311771-test11",
"provisioningState": "Succeeded",
"resourceGroup": "ServerlessDevSetup",
"sourceVirtualMachine": {
"id": "/subscriptions//resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/virtualMachines/pkrvmv3ko4te2bd",
"resourceGroup": "ServerlessDevSetup"
},
"storageProfile": {
"dataDisks": [],
"osDisk": {
"blobUri": null,
"caching": "ReadWrite",
"diskEncryptionSet": null,
"diskSizeGb": 128,
"managedDisk": {
"id": "/subscriptions/
/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd",
"resourceGroup": "ServerlessDevSetup"
},
"osState": "Generalized",
"osType": "Linux",
"snapshot": null,
"storageAccountType": "Standard_LRS"
},
"zoneResilient": false
},
"tags": {
"ALERTGROUP": "AZURE_SERVERLESS_DEV_TEAM",
"AMINAME": "packercldagnt-serverless-westus-MLR4311771-test11",
"APPLICATIONENV": "DEV",
"APPLICATIONROLE": "CICD",
"BUSINESSENTITY": "INTCLOUD",
"BUSINESSUNIT": "IAS",
"NAME": "packercldagnt-serverless-westus-MLR4311771-test11",
"OS": "LINUX",
"OWNEREMAIL": "[email protected]",
"POD": "NONPROD",
"RUNNINGSCHEDULE": "00:00:23:59:1-7",
"SERVICENAME": "packer",
"SKIPAUTOCONFIG": "YES",
"SOURCEAMI": "ServerlessDevSetup/"
},
"type": "Microsoft.Compute/images"
}

DEBUG: cli.azext_imagecopy.cli_utils: json output starts at position: 0
DEBUG: cli.azext_imagecopy.cli_utils: command: ['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'disk', 'show', '--ids', '/subscriptions//resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--output', 'tsv'] ended with output: None None None None None None 500 None 60 137438953472 128 Reserved None None V1 /subscriptions//resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd westus /subscriptions/************************************/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/virtualMachines/pkrvmv3ko4te2bd None None pkrosv3ko4te2bd AllowAll None Linux None Succeeded Enabled None ServerlessDevSetup None None None None 2023-08-02T14:10:48.567580+00:00 Microsoft.Compute/disks 1a58207a-b9aa-40dd-afe9-6187407ce2b9 None

DEBUG: cli.azext_imagecopy.custom: found DISK: /subscriptions//resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd
DEBUG: cli.azext_imagecopy.custom: source_os_disk_type: DISK. source_os_disk_id: /subscriptions/
/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd. source_os_type: Linux
WARNING: cli.azext_imagecopy.custom: Creating source snapshot
ERROR: cli.azext_imagecopy.cli_utils: command failed: ['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions/************************************/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']
ERROR: cli.azext_imagecopy.cli_utils: output: ERROR: (RequestDisallowedByPolicy) Resource 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot' was disallowed by policy. Reasons: 'Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement'. See error details for policy resource IDs.
Code: RequestDisallowedByPolicy
Message: Resource 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot' was disallowed by policy. Reasons: 'Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement'. See error details for policy resource IDs.
Target: packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot
Additional Information:Type: PolicyViolation
Info: {
"evaluationDetails": {
"evaluatedExpressions": [
{
"result": "True",
"expressionKind": "Field",
"expression": "type",
"path": "type",
"expressionValue": "Microsoft.Compute/snapshots",
"targetValue": [
"microsoft.compute/virtualmachines",
"microsoft.compute/disks",
"microsoft.compute/snapshots",
"microsoft.compute/virtualmachinescalesets",
"microsoft.containerservice/managedclusters",
"microsoft.dbformysql/flexibleservers",
"microsoft.dbformysql/servers",
"microsoft.network/applicationgateways",
"microsoft.network/loadbalancers",
"microsoft.network/networkinterfaces",
"microsoft.network/publicipaddresses",
"microsoft.network/virtualnetworks",
"microsoft.sql/servers",
"microsoft.sql/servers/databases",
"microsoft.storage/storageaccounts",
"microsoft.HDInsight/clusterPools",
"microsoft.HDInsight/clusterPools/clusters",
"microsoft.HDInsight/clusters"
],
"operator": "In"
},
{
"result": "True",
"expressionKind": "Field",
"expression": "tags[BUSINESSUNIT]",
"path": "tags[BUSINESSUNIT]",
"targetValue": "false",
"operator": "Exists"
}
],
"reason": "Mandatory Tags (BUSINESSUNIT, BUSINESSENTITY, OWNEREMAIL) are missing. For more details please go through the wiki https://infawiki.informatica.com/display/IRM/NON-Cogs+RnD+account+Tagging+Enforcement"
},
"policyDefinitionId": "/providers/Microsoft.Management/managementGroups/IT-NonProd-Azure-Management-Group-For-RnD/providers/Microsoft.Authorization/policyDefinitions/92acf9b8-42b0-468c-aa61-b267594cf5ae",
"policyDefinitionName": "92acf9b8-42b0-468c-aa61-b267594cf5ae",
"policyDefinitionDisplayName": "R&D-Tag-Enforcement-Definition",
"policyDefinitionEffect": "deny",
"policyAssignmentId": "/providers/Microsoft.Management/managementGroups/IT-NonProd-Azure-Management-Group-For-RnD/providers/Microsoft.Authorization/policyAssignments/ee40811860064c28897b34a3",
"policyAssignmentName": "ee40811860064c28897b34a3",
"policyAssignmentDisplayName": "R&D-Tag-Enforcement-Definition",
"policyAssignmentScope": "/providers/Microsoft.Management/managementGroups/IT-NonProd-Azure-Management-Group-For-RnD",
"policyAssignmentParameters": {
"tagName1": "BUSINESSUNIT",
"tagName2": "BUSINESSENTITY",
"tagName3": "OWNEREMAIL",
"enforcedresources": [
"microsoft.compute/virtualmachines",
"microsoft.compute/disks",
"microsoft.compute/snapshots",
"microsoft.compute/virtualmachinescalesets",
"microsoft.containerservice/managedclusters",
"microsoft.dbformysql/flexibleservers",
"microsoft.dbformysql/servers",
"microsoft.network/applicationgateways",
"microsoft.network/loadbalancers",
"microsoft.network/networkinterfaces",
"microsoft.network/publicipaddresses",
"microsoft.network/virtualnetworks",
"microsoft.sql/servers",
"microsoft.sql/servers/databases",
"microsoft.storage/storageaccounts",
"microsoft.HDInsight/clusterPools",
"microsoft.HDInsight/clusterPools/clusters",
"microsoft.HDInsight/clusters"
]
},
"policyExemptionIds": []
}

DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/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/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(args, kwargs)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(command_args)
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/custom.py", line 128, in imagecopy
run_cli_command(cli_cmd)
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/cli_utils.py", line 45, in run_cli_command
raise ex
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/cli_utils.py", line 21, in run_cli_command
cmd_output = check_output(cmd, stderr=STDOUT, universal_newlines=True)
File "/usr/local/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 421, in check_output
return run(popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/local/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions/
******************************/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']' returned non-zero exit status 1.

ERROR: cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
ERROR: az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
ERROR: cli.azure.cli.core.azclierror: Command '['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions//resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']' returned non-zero exit status 1.
Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/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/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(args, kwargs)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(command_args)
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/custom.py", line 128, in imagecopy
run_cli_command(cli_cmd)
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/cli_utils.py", line 45, in run_cli_command
raise ex
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/cli_utils.py", line 21, in run_cli_command
cmd_output = check_output(cmd, stderr=STDOUT, universal_newlines=True)
File "/usr/local/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 421, in check_output
return run(popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/local/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions/
/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']' returned non-zero exit status 1.
ERROR: az_command_data_logger: Command '['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions/
/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']' returned non-zero exit status 1.
Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/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/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(args, kwargs)
File "/usr/local/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(command_args)
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/custom.py", line 128, in imagecopy
run_cli_command(cli_cmd)
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/cli_utils.py", line 45, in run_cli_command
raise ex
File "/Users/rdhanase/.azure/cliextensions/image-copy-extension/azext_imagecopy/cli_utils.py", line 21, in run_cli_command
cmd_output = check_output(cmd, stderr=STDOUT, universal_newlines=True)
File "/usr/local/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 421, in check_output
return run(popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/local/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/Cellar/azure-cli/2.50.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--name', 'packercldagnt-serverless-westus-MLR4311771-test11_os_disk_snapshot', '--location', 'westus', '--resource-group', 'ServerlessDevSetup', '--source', '/subscriptions/
/resourceGroups/ServerlessDevSetup/providers/Microsoft.Compute/disks/pkrosv3ko4te2bd', '--hyper-v-generation', 'V1', '--output', 'json', '--tags', 'created_by=image-copy-extension']' returned non-zero exit status 1.
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x10bc07130>]
INFO: az_command_data_logger: exit code: 1
INFO: cli.main: Command ran in 4.566 seconds (init: 0.161, invoke: 4.406)
INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
INFO: telemetry.client: Accumulated 0 events. Flush the clients.
INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1
INFO: telemetry.save: Save telemetry record of length 8146 in cache
WARNING: telemetry.check: Negative: The /Users/rdhanase/.azure/telemetry.txt was modified at 2023-08-10 11:55:05.562099, which in less than 600.000000 s

Expected behavior

The command 'az copy image' should work with the necessary tags getting properly.

Environment Summary

azure-cli 2.50.0 *

core 2.50.0 *
telemetry 1.0.8 *

Extensions:
account 0.2.5
image-copy-extension 0.2.13
interactive 0.4.6
storage-preview 0.8.4

Dependencies:
msal 1.22.0
azure-mgmt-resource 23.1.0b2

Additional context

No response

@rdhanase rdhanase added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Aug 10, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Aug 10, 2023

Thank you for opening this issue, we will look into it.

@microsoft-github-policy-service microsoft-github-policy-service bot added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. Compute labels Aug 10, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team labels Aug 10, 2023
@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Aug 10, 2023
@yonzhan yonzhan added this to the Backlog milestone Aug 10, 2023
@yanzhudd
Copy link
Contributor

yanzhudd commented Aug 18, 2023

Hi @rdhanase
actually, the image copy command would create some temporary resources which should be invisible to users and would be deleted after the final image being created.
This issue is caused by not passing --tags to create snapshot (one of the temporary resources), and this behavior is by design.
It is an edge case for image copy command. If you need to pass --tags to create middle resources, please open a GitHub feature request.
In order to unblock your process, we recommend to use Azure Compute Gallery as better alternatives. In fact, it is more powerful than image-copy extension and is our recommended substitute for image copy.

@yonzhan yonzhan closed this as completed Sep 4, 2023
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 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