From 8b867266f925e264902d21e49e8e86c48ed500d5 Mon Sep 17 00:00:00 2001 From: Lili Deng Date: Wed, 13 Dec 2023 13:12:03 +0800 Subject: [PATCH] skip case if 'Public access is not permitted on this storage account' --- .../vm_extensions/runtime_extensions/common.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/microsoft/testsuites/vm_extensions/runtime_extensions/common.py b/microsoft/testsuites/vm_extensions/runtime_extensions/common.py index 110b20d489..a603a0bf54 100644 --- a/microsoft/testsuites/vm_extensions/runtime_extensions/common.py +++ b/microsoft/testsuites/vm_extensions/runtime_extensions/common.py @@ -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 @@ -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