Restore name-availability error enrichment and null-result guard#29693
Merged
YanaXu merged 1 commit intoMay 27, 2026
Merged
Conversation
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.
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
YanaXu
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #29691. Restores the
Reason/Messageerror enrichment on theNameAvailable=falsepath inValidateFunctionAppNameAvailabilitythat wasinadvertently removed when reverting #29687, and adds a null-result guard for
Test-AzNameAvailability.Changes
src/Functions/Functions.Autorest/custom/HelperFunctions.ps1:FunctionAppNameAvailabilityCheckFailederror if
Test-AzNameAvailabilityreturns$null(e.g., REST 204 / empty body)instead of silently NRE-ing on
$result.NameAvailable.Reason/Messageenrichment — 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 SilentlyContinueon theTest-AzNameAvailabilitycall — that splatting interaction with@PSBoundParameterswas the actual root cause of the PS 5.1 break in #29687.Write-Warningdiagnostic block from Add diagnostics to ValidateFunctionAppNameAvailability for PS 5.1 debugging #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
New-AzFunctionAppwith a taken name → enriched errorNew-AzFunctionAppwith an available name → succeedsFunctionAppNameIsNullOrEmpty)Description
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.