Skip to content

Commit

Permalink
skip case if 'Public access is not permitted on this storage account'
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Dec 15, 2023
1 parent 1ce2571 commit 8b86726
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions microsoft/testsuites/vm_extensions/runtime_extensions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Dict, Optional

from assertpy import assert_that
from azure.core.exceptions import ResourceExistsError
from azure.storage.blob import BlobType

from lisa import Node
Expand Down Expand Up @@ -108,9 +109,20 @@ def retrieve_storage_blob_url(
blob = container_client.get_blob_client(blob_name)
if not blob.exists():
if is_public_container:
container_client.set_container_access_policy(
signed_identifiers={}, public_access="container"
)
try:
container_client.set_container_access_policy(
signed_identifiers={}, public_access="container"
)
except ResourceExistsError as ex:
if (
"public access is not permitted on this storage account"
in str(ex).lower()
):
raise SkippedException(
"Public access is not permitted on this storage account "
f"{storage_account_name}. {ex}"
)
raise ex
# Upload blob to container if doesn't exist
container_client.upload_blob(
name=blob_name, data=blob_data, blob_type=blob_type # type: ignore
Expand Down

0 comments on commit 8b86726

Please sign in to comment.