diff --git a/sky/cloud_stores.py b/sky/cloud_stores.py index dae63c36e12..b430e57ecd5 100644 --- a/sky/cloud_stores.py +++ b/sky/cloud_stores.py @@ -219,8 +219,7 @@ def is_directory(self, url: str) -> bool: container_url = data_utils.AZURE_CONTAINER_URL.format( storage_account_name=storage_account_name, container_name=container_name) - resource_group_name = data_utils.get_az_resource_group( - storage_account_name) + resource_group_name = azure.get_az_resource_group(storage_account_name) role_assignment_start = time.time() refresh_client = False role_assigned = False diff --git a/sky/data/data_utils.py b/sky/data/data_utils.py index fafbe5542c3..78c49bc95e4 100644 --- a/sky/data/data_utils.py +++ b/sky/data/data_utils.py @@ -204,7 +204,7 @@ def verify_az_bucket(storage_account_name: str, container_name: str) -> bool: container_url = AZURE_CONTAINER_URL.format( storage_account_name=storage_account_name, container_name=container_name) - resource_group_name = get_az_resource_group(storage_account_name) + resource_group_name = azure.get_az_resource_group(storage_account_name) container_client = create_az_client( client_type='container', container_url=container_url, @@ -213,37 +213,6 @@ def verify_az_bucket(storage_account_name: str, container_name: str) -> bool: return container_client.exists() -def get_az_resource_group( - storage_account_name: str, - storage_client: Optional[Client] = None) -> Optional[str]: - """Returns the resource group name the given storage account belongs to. - - Args: - storage_account_name: Name of the storage account - storage_client: Client object facing storage - - Returns: - Name of the resource group the given storage account belongs to, or - None if not found. - """ - if storage_client is None: - storage_client = create_az_client('storage') - for account in storage_client.storage_accounts.list(): - if account.name == storage_account_name: - # Extract the resource group name from the account ID - # An example of account.id would be the following: - # /subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Storage/storageAccounts/{container_name} # pylint: disable=line-too-long - split_account_id = account.id.split('/') - assert len(split_account_id) == 9 - resource_group_name = split_account_id[4] - return resource_group_name - # resource group cannot be found when using container not created - # under the user's subscription id, i.e. public container, or - # private containers not belonging to the user or when the storage account - # does not exist. - return None - - def get_az_storage_account_key( storage_account_name: str, resource_group_name: Optional[str] = None,