Skip to content

Commit 276bda9

Browse files
authored
Update custom.py
1 parent 1c20fa6 commit 276bda9

File tree

1 file changed

+11
-0
lines changed
  • src/azure-cli/azure/cli/command_modules/appservice

1 file changed

+11
-0
lines changed

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,18 @@ def update_application_settings_polling(cmd, resource_group_name, name, app_sett
579579

580580
def add_azure_storage_account(cmd, resource_group_name, name, custom_id, storage_type, account_name,
581581
share_name, access_key, mount_path=None, slot=None, slot_setting=False):
582+
583+
from azure.storage.fileshare import ShareServiceClient
582584
AzureStorageInfoValue = cmd.get_models('AzureStorageInfoValue')
585+
586+
# Check if the file share exists
587+
share_service_client = ShareServiceClient(account_url=f"https://{account_name}.file.core.windows.net",
588+
credential=access_key)
589+
file_shares = share_service_client.list_shares()
590+
share_names = [share.name for share in file_shares]
591+
if share_name not in share_names:
592+
raise ValidationError(f"The share '{share_name}' does not exist in the storage account '{account_name}'.")
593+
583594
azure_storage_accounts = _generic_site_operation(cmd.cli_ctx, resource_group_name, name,
584595
'list_azure_storage_accounts', slot)
585596

0 commit comments

Comments
 (0)