Skip to content

Commit

Permalink
Print a better error upon Azure permission errors (#472)
Browse files Browse the repository at this point in the history
* Print a better error upon Azure permission errors

* Format code
  • Loading branch information
parasj authored Jul 27, 2022
1 parent 8d10f3e commit 9da5936
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions skyplane/obj_store/azure_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9da5936

Please sign in to comment.