microsoft / azserialconsole

Azure Serial Console
17 stars 11 forks source link

Serial-console fails for systems in eastus #106

Closed msftvito closed 1 year ago

msftvito commented 1 year ago

This is for an issue originally opened at https://github.com/Azure/azure-cli/issues/26050.

az serial-console connect fails because the dictionary used for looking up region pairs doesn't have eastus. Official Azure documentation lists the pair for eastus is westus: https://learn.microsoft.com/en-us/azure/reliability/cross-region-replication-azure.

Proposed fix: _arm_endpoints.py should add this to the dictionary: 'eastus': 'westus',

Error message on with version 0.1.5 of the serial-console extension on Linux: The command failed with an unexpected error. Here is the traceback: 'eastus' Traceback (most recent call last): File "/usr/lib64/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/usr/lib64/az/lib/python3.6/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.6/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(*args, kwargs) File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/home/vito/.azure/cliextensions/serial-console/azext_serialconsole/custom.py", line 633, in connect_serialconsole vm_vmss_name, vmss_instanceid) File "/home/vito/.azure/cliextensions/serial-console/azext_serialconsole/custom.py", line 597, in check_resource vmss_instanceid) File "/home/vito/.azure/cliextensions/serial-console/azext_serialconsole/custom.py", line 735, in get_region_from_storage_account storage_account_region = get_storage_account_info(storage_account_url, scf) File "/home/vito/.azure/cliextensions/serial-console/azext_serialconsole/custom.py", line 750, in get_storage_account_info return ArmEndpoints.region_prefix_pairings[sa_result.location] KeyError: 'eastus' To open an issue, please run: 'az feedback'

To reproduce: az serial-console connect -n vmname -g vmresourcegroup on a VM in the eastus region, with the boot diagnostics storage account set to a custom storage account instead of the default managed storage account, otherwise get_storage_account_info will return None instead of looking up the region_prefix_pairings dictionary:

`def get_storage_account_info(storage_account_url, scf): from azext_serialconsole._arm_endpoints import ArmEndpoints

if storage_account_url is not None: storage_account, storage_account_resource_group = parse_storage_account_url(storage_account_url, scf) if storage_account is not None: sa_result = scf.storage_accounts.get_properties(storage_account_resource_group, storage_account) if (sa_result is not None and sa_result.network_rule_set is not None and len(sa_result.network_rule_set.ip_rules) > 0): return ArmEndpoints.region_prefix_pairings[sa_result.location] return None`

rhkodiak commented 1 year ago

Hi @msftvito - here is the PR to address the fix for this issue https://github.com/Azure/azure-cli-extensions/pull/6231

msftvito commented 1 year ago

Thank you! I'll close this when the PR goes through.

rhkodiak commented 1 year ago

The PR closed so I'm closing this issue.