From a1b03cc79005c22089db585f86af84a0ad704310 Mon Sep 17 00:00:00 2001 From: Hualiang Xu Date: Thu, 22 Jan 2026 15:42:22 -0500 Subject: [PATCH] Fix delete pending flag as file/dir not exists --- .../cli/command_modules/storage/operations/fileshare.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/storage/operations/fileshare.py b/src/azure-cli/azure/cli/command_modules/storage/operations/fileshare.py index 272e5a9f049..155c5219179 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/operations/fileshare.py +++ b/src/azure-cli/azure/cli/command_modules/storage/operations/fileshare.py @@ -119,10 +119,18 @@ def _get_client(client, kwargs): dir_client = client.get_directory_client(directory_path=total_path) exists = False from azure.core.exceptions import ClientAuthenticationError + from azure.core.exceptions import ResourceExistsError try: exists = dir_client.exists() except ClientAuthenticationError: exists = False + except ResourceExistsError as ex: + if hasattr(ex, "error_code") and ex.error_code == "DeletePending": + # translate delete pending flag as file/dir not exists. + exists = False + else: + raise ex + if not exists: dir_client = client.get_directory_client(directory_path=directory_path) client = dir_client.get_file_client(file_name=file_name)