Skip to content

Commit 7b773cd

Browse files
authored
[App Service] Fix: #21721: az webapp config storage-account add: Add validation for non-existent FileShare (#30990)
1 parent f47f7b4 commit 7b773cd

File tree

3 files changed

+1068
-685
lines changed

3 files changed

+1068
-685
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,14 @@ def update_application_settings_polling(cmd, resource_group_name, name, app_sett
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):
582582
AzureStorageInfoValue = cmd.get_models('AzureStorageInfoValue')
583+
storage_client = get_mgmt_service_client(cmd.cli_ctx, StorageManagementClient)
584+
585+
# Check if the file share exists
586+
try:
587+
storage_client.file_shares.get(resource_group_name, account_name, share_name)
588+
except:
589+
raise ValidationError(f"The share '{share_name}' does not exist in the storage account '{account_name}'.")
590+
583591
azure_storage_accounts = _generic_site_operation(cmd.cli_ctx, resource_group_name, name,
584592
'list_azure_storage_accounts', slot)
585593

0 commit comments

Comments
 (0)