Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
383 stars 1.24k forks source link

az serial-console connect with log storage in other RG than VM give a not found error #5734

Open freedge opened 1 year ago

freedge commented 1 year ago

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):
ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

yonzhan commented 1 year ago

route to CXP team

SaurabhSharma-MSFT commented 1 year ago

@freedge I am able to reproduce this issue and checking internally on the same.

yatamlite commented 1 year ago

We use a dedicated SA for storing boot diagnostics for all VMs deployed across an organization. When is this bug expected to be fixed?

microsoft-github-policy-service[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @CraigWiand.