Skip to content

Conversation

Copy link

Copilot AI commented Jun 4, 2025

The storage account name validation in interactive mode was failing with incomplete error messages when Azure CLI errors occurred. Users would see truncated messages like:

Storage account name 'sttestdev300' is not available:

Instead of helpful information about why the validation failed.

Root Cause

The issue had two parts:

  1. Azure CLI errors were suppressed: The 2>$null redirection meant authentication errors and other CLI failures were hidden, causing ConvertFrom-Json to receive no input and return null
  2. Case-insensitive regex: PowerShell's default -notmatch operator is case-insensitive, so format validation wasn't catching uppercase letters properly

Changes Made

  • Enhanced error handling: Capture Azure CLI stderr with 2>&1 and check $LASTEXITCODE to detect CLI failures
  • Improved error messages: Provide specific, actionable error messages for different failure scenarios:
    • Format errors: "Storage account name must be 3-24 lowercase alphanumeric characters."
    • CLI authentication errors: "Storage account name 'name' could not be validated. Azure CLI error: Please run 'az login' to setup account."
    • Name unavailable: "Storage account name 'name' is not available: The storage account named name is already taken."
  • Fixed regex case sensitivity: Use -cnotmatch for case-sensitive format validation
  • Added comprehensive test coverage: 9 test cases covering all error scenarios
  • Cleanup: Removed duplicate unused Test-StorageAccountName.ps1 file

Testing

The fix now handles all failure scenarios gracefully:

# Format validation works correctly
Test-AzStorageAccountName -StorageAccountName "TestAccount"
# Error: Storage account name must be 3-24 lowercase alphanumeric characters.

# Authentication issues are clear
Test-AzStorageAccountName -StorageAccountName "validname123" 
# Error: Storage account name 'validname123' could not be validated. Azure CLI error: Please run 'az login' to setup account.

Fixes #57.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: kewalaka <3146590+kewalaka@users.noreply.github.com>
Copilot AI changed the title [WIP] Storage account name availability check fails without meaningful error in interactive mode Fix storage account name availability check to provide meaningful error messages Jun 4, 2025
Copilot AI requested a review from kewalaka June 4, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storage account name availability check fails without meaningful error in interactive mode

1 participant