Skip to content

Restore name-availability error enrichment and null-result guard#29693

Merged
YanaXu merged 1 commit into
Azure:fix-live-test-functionsfrom
Francisco-Gamino:functions-fix-app-name-availability
May 27, 2026
Merged

Restore name-availability error enrichment and null-result guard#29693
YanaXu merged 1 commit into
Azure:fix-live-test-functionsfrom
Francisco-Gamino:functions-fix-app-name-availability

Conversation

@Francisco-Gamino

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #29691. Restores the Reason/Message error enrichment on the
NameAvailable=false path in ValidateFunctionAppNameAvailability that was
inadvertently removed when reverting #29687, and adds a null-result guard for
Test-AzNameAvailability.

Changes

src/Functions/Functions.Autorest/custom/HelperFunctions.ps1:

  1. New null-result guard — surfaces a clear FunctionAppNameAvailabilityCheckFailed
    error if Test-AzNameAvailability returns $null (e.g., REST 204 / empty body)
    instead of silently NRE-ing on $result.NameAvailable.
  2. Restored Reason/Message enrichment — when the service rejects a name,
    the error message now again includes the service's reason text so users can
    distinguish "already taken" from "invalid characters", etc.

What this does NOT reintroduce

--ErrorVariable nameCheckError -ErrorAction SilentlyContinue on the
Test-AzNameAvailability call — that splatting interaction with
@PSBoundParameters was the actual root cause of the PS 5.1 break in #29687.

Risk

Very low. Purely additive. No change to the existing happy path. Existing
failure path keeps the same error ID (FunctionAppNameIsNotAvailable),
exception type, and category — only the message gets richer when the service
provides a reason. No AutoRest regeneration required (custom/ only).

Testing

  • PS 5.1 and PS 7.x manual New-AzFunctionApp with a taken name → enriched error
  • PS 5.1 and PS 7.x manual New-AzFunctionApp with an available name → succeeds
  • Empty/null name → unchanged (FunctionAppNameIsNullOrEmpty)

Description

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Adds back the Reason/Message enrichment on the NameAvailable=false path that was inadvertently removed in PR Azure#29691, and introduces a null-result guard for the Test-AzNameAvailability call. Does not reintroduce the -ErrorVariable/-ErrorAction SilentlyContinue splatting from Azure#29687 which caused the PS 5.1 break.
@azure-client-tools-bot-prd

Copy link
Copy Markdown
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@Francisco-Gamino Francisco-Gamino requested a review from JunKai-v May 26, 2026 21:42
@thomas-temby

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 3 pipeline(s).

@YanaXu YanaXu merged commit 8bbdbf5 into Azure:fix-live-test-functions May 27, 2026
12 checks passed
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.

3 participants