The VM does not have previous data disks, but has one OS disk.
The command failed with an unexpected error. Here is the traceback:
'NoneType' object has no attribute 'image_reference'
Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/vm/custom.py", line 4304, in attach_managed_data_disk_to_vmss
vmss_vm.storage_profile.image_reference = None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'image_reference'
DEBUG: cli.knack.cli: Command arguments: ['vmss', 'disk', 'attach', '-g', 'redacted-rg-appl-dev', '--vmss-name', 'redacted-vmss-appl-dev-tcx4', '--instance-id', 'redacted-vmss-appl-dev_46a95f42', '--disk', 'redacted-dsk-appl-dev-tcx4', '--lun', '0', '--debug']
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 0x7f8a6dc87f60>, <function OutputProducer.on_global_arguments at 0x7f8a6dc36160>, <function CLIQuery.on_global_arguments at 0x7f8a6dc73c40>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'vmss': ['azure.cli.command_modules.vm']
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.202 60 241
DEBUG: cli.azure.cli.core: Total (1) 0.202 60 241
DEBUG: cli.azure.cli.core: Loaded 60 groups, 241 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command : vmss disk attach
DEBUG: cli.azure.cli.core: Command table: vmss disk attach
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f8a6d095d00>]
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/root/.azure/commands/2024-10-03.13-43-26.vmss_disk_attach.3542.log'.
INFO: az_command_data_logger: command args: vmss disk attach -g {} --vmss-name {} --instance-id {} --disk {} --lun {} --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f8a6ceea3e0>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f8a6ceea480>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f8a6ceea5c0>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x7f8a6ceea660>]
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 0x7f8a6dc36200>, <function CLIQuery.handle_query_parameter at 0x7f8a6dc73ce0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f8a6ceea520>]
DEBUG: cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ComputeManagementClient
DEBUG: urllib3.connectionpool: Starting new HTTP connection (1): 169.254.169.254:80
DEBUG: urllib3.connectionpool: http://169.254.169.254:80 "GET /metadata/identity/oauth2/token?resource=https%3A%2F%2Fmanagement.core.windows.net%2F&api-version=2018-02-01 HTTP/1.1" 200 2224
DEBUG: msrestazure.azure_active_directory: MSI: Retrieving a token from http://169.254.169.254/metadata/identity/oauth2/token, with payload {'resource': 'https://management.core.windows.net/', 'api-version': '2018-02-01'}
DEBUG: msrestazure.azure_active_directory: MSI: Token retrieved
DEBUG: cli.azure.cli.core.auth.adal_authentication: MSIAuthenticationWrapper.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
INFO: msrestazure.azure_active_directory: MSI: token is found in cache.
DEBUG: cli.azure.cli.core.auth.adal_authentication: Normalize expires_on: '1728047015' -> 1728047015
DEBUG: cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/subscription_id/resourceGroups/redacted-rg-appl-dev/providers/Microsoft.Compute/virtualMachineScaleSets/redacted-vmss-appl-dev-tcx4/virtualMachines/redacted-vmss-appl-dev_46a95f42?api-version=2024-07-01'
DEBUG: cli.azure.cli.core.sdk.policies: Request method: 'GET'
DEBUG: cli.azure.cli.core.sdk.policies: Request headers:
DEBUG: cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '7728824d-818d-11ef-a2cf-278335739003'
DEBUG: cli.azure.cli.core.sdk.policies: 'CommandName': 'vmss disk attach'
DEBUG: cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-g --vmss-name --instance-id --disk --lun --debug'
DEBUG: cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.64.0 (DEB) azsdk-python-core/1.28.0 Python/3.11.8 (Linux-5.15.0-1073-azure-x86_64-with-glibc2.31)'
DEBUG: cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
DEBUG: cli.azure.cli.core.sdk.policies: Request body:
DEBUG: cli.azure.cli.core.sdk.policies: This request has no body
DEBUG: urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
DEBUG: urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/subscription_id/resourceGroups/redacted-rg-appl-dev/providers/Microsoft.Compute/virtualMachineScaleSets/redacted-vmss-appl-dev-tcx4/virtualMachines/redacted-vmss-appl-dev_46a95f42?api-version=2024-07-01 HTTP/1.1" 200 528
DEBUG: cli.azure.cli.core.sdk.policies: Response status: 200
DEBUG: cli.azure.cli.core.sdk.policies: Response headers:
DEBUG: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
DEBUG: cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Length': '528'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
DEBUG: cli.azure.cli.core.sdk.policies: 'Expires': '-1'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-resource': 'Microsoft.Compute/GetVMScaleSetVMSubscriptionMaximum;5998,Microsoft.Compute/GetVMScaleSetVMResource;34,Microsoft.Compute/VMScaleSetVMViewsSubscriptionMaximum;29998'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-request-charge': '1'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-need-to-refresh-epl-cache': 'False'
DEBUG: cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'b90629de-6220-4cf7-87e2-2146e8d8c229'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-reads': '249'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-reads': '3749'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '4b612161-0d4d-47b2-be81-8032a81e2e22'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'CANADACENTRAL:20241003T134326Z:4b612161-0d4d-47b2-be81-8032a81e2e22'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: E3A783816D1547F4B87D64F94DA8FE02 Ref B: YTO221090812025 Ref C: 2024-10-03T13:43:26Z'
DEBUG: cli.azure.cli.core.sdk.policies: 'Date': 'Thu, 03 Oct 2024 13:43:26 GMT'
DEBUG: cli.azure.cli.core.sdk.policies: Response content:
DEBUG: cli.azure.cli.core.sdk.policies: {
"name": "redacted-vmss-appl-dev_46a95f42",
"id": "/subscriptions/subscription_id/resourceGroups/redacted-rg-appl-dev/providers/Microsoft.Compute/virtualMachineScaleSets/redacted-vmss-appl-dev-tcx4/virtualMachines/redacted-vmss-appl-dev_46a95f42",
"type": "Microsoft.Compute/virtualMachineScaleSets/virtualMachines",
"location": "CanadaCentral",
"instanceId": "redacted-vmss-appl-dev_46a95f42",
"zones": [
null
]
}
DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/vm/custom.py", line 4304, in attach_managed_data_disk_to_vmss
vmss_vm.storage_profile.image_reference = None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'image_reference'
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: 'NoneType' object has no attribute 'image_reference'
Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/vm/custom.py", line 4304, in attach_managed_data_disk_to_vmss
vmss_vm.storage_profile.image_reference = None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'image_reference'
ERROR: az_command_data_logger: 'NoneType' object has no attribute 'image_reference'
Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/vm/custom.py", line 4304, in attach_managed_data_disk_to_vmss
vmss_vm.storage_profile.image_reference = None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'image_reference'
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 0x7f8a6d095f80>]
INFO: az_command_data_logger: exit code: 1
INFO: cli.__main__: Command ran in 0.685 seconds (init: 0.121, invoke: 0.564)
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 7943 in cache file under /root/.azure/telemetry/20241003134326792
INFO: telemetry.main: Begin creating telemetry upload process.
INFO: telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /root/.azure /root/.azure/telemetry/20241003134326792"
INFO: telemetry.process: Return from creating process 3548
INFO: telemetry.main: Finish creating telemetry upload process.
The disk is attached as data disk to the virtual machine. This works when the VMSS is not an orchestrated vmss.
Your CLI is up-to-date.
Describe the bug
Running the command
az vmss disk attach -g {} --vmss-name {} --instance-id {} --disk {} --lun 0on existing virtual machine and existing disk results in error:'NoneType' object has no attribute 'image_reference'The VM does not have previous data disks, but has one OS disk.
Related command
az vmss disk attach -g {} --vmss-name {} --instance-id {} --disk {} --lun 0Errors
Issue script & Debug output
Expected behavior
The disk is attached as data disk to the virtual machine. This works when the VMSS is not an orchestrated vmss.
Environment Summary
azure-cli 2.64.0
core 2.64.0
telemetry 1.1.0
Dependencies:
msal 1.30.0
azure-mgmt-resource 23.1.1
Python location '/opt/az/bin/python3'
Extensions directory '/root/.azure/cliextensions'
Python (Linux) 3.11.8 (main, Aug 28 2024, 05:45:28) [GCC 9.4.0]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
No response