Azure / Azure/azure-cli-extensions
az serial-console connect with log storage in other RG than VM give a not found error
- Dominant language
- Python
- Stars
- 454
- Forks
- 1.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 64
Description
dup of closed ticket https://github.com/Azure/azure-cli-extensions/issues/5535
### Related command
az serial-console connect
### Extension name (the extension in question)
serial-console
### Description of issue (in as much detail as possible)
when creating a VM in one resource group, while having the boot-diagnostics in a storage account in a different resource group, az serial-console connect fails with
```
(ResourceNotFound) The Resource 'Microsoft.Storage/storageAccounts/A' under resource group 'G' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound
Message: The Resource 'Microsoft.Storage/storageAccounts/A' under resource group 'G' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
```
this is due to get_storage_account_info function using the VM resource group provided, to get properties for a storage account which it assumes would be in the same resource group. I attach a following patch (that extract all the storage accounts and look for the right one) which works for me, although it getx more data from Azure and needs the user to have rights to list service accounts. Maybe removing the entire "check_serial_console_enabled" logic would be more efficient. Thanks
```
--- ./serial-console/azext_serialconsole/custom.py 2023-01-06 16:00:13.534739430 +0100
+++ ./serial-console/azext_serialconsole/custom.py 2023-01-06 16:44:48.221515726 +0100
@@ -744,7 +744,12 @@
if storage_account_url is not None:
storage_account = parse_storage_account_url(storage_account_url)
if storage_account is not None:
- sa_result = scf.storage_accounts.get_properties(resource_group_name, storage_account)
+ sa_result = None
+ for sa in scf.storage_accounts.list():
+ if sa.name == storage_account:
+ sa_result = sa
+ break
+
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):
```
Contributor guide
Assessment
This issue has not been assessed yet.