From 9da59363e8295bb175f91ee68a80a94408c9997a Mon Sep 17 00:00:00 2001 From: Paras Jain Date: Tue, 26 Jul 2022 18:16:46 -0700 Subject: [PATCH] Print a better error upon Azure permission errors (#472) * Print a better error upon Azure permission errors * Format code --- skyplane/obj_store/azure_interface.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/skyplane/obj_store/azure_interface.py b/skyplane/obj_store/azure_interface.py index e46c74e09..47871978a 100644 --- a/skyplane/obj_store/azure_interface.py +++ b/skyplane/obj_store/azure_interface.py @@ -143,8 +143,14 @@ def delete_bucket(self): def list_objects(self, prefix="") -> Iterator[AzureObject]: blobs = self.container_client.list_blobs(name_starts_with=prefix) - for blob in blobs: - yield AzureObject("azure", f"{self.account_name}/{blob.container}", blob.name, blob.size, blob.last_modified) + try: + for blob in blobs: + yield AzureObject("azure", f"{self.account_name}/{blob.container}", blob.name, blob.size, blob.last_modified) + except HttpResponseError as e: + if "AuthorizationPermissionMismatch" in str(e): + logger.error( + f"Unable to list objects in container {self.container_name} as you don't have permission to access it. You need the 'Storage Blob Data Contributor' and 'Storage Account Contributor' roles." + ) def delete_objects(self, keys: List[str]): for key in keys: