Output should be consistent when resource already exists
Related command Creating app registration
az ad app create `
--display-name $hostname `
--web-home-page-url $replyUrls[0] `
--required-resource-accesses "@ApiPermissions.json" `
--app-roles "@AppRoles.json" `
--enable-id-token-issuance true `
--sign-in-audience AzureADMyOrg
White output: WARNING: Found an existing application instance: (id) [REDACTED]. We will patch it.
Notice that it says 'WARNING' but is not colored.
Creating key vault
az keyvault create --name $hostname --resource-group $ResourceGroupName --enable-rbac-authorization true
Red output: The specified vault: myapp already exists
Creating app service
az webapp create `
--resource-group $ResourceGroupName `
--name $AppServiceName `
--plan $AppServicePlanName `
--runtime "DOTNETCORE:8.0" `
--https-only true
Yellow output: Webapp 'myapp' already exists. The command will use the existing app's settings.
Creating function app with flex consumption plan
az functionapp create `
--resource-group $ResourceGroupName `
--name $functionAppName `
--storage-account $AppServiceName `
--flexconsumption-location $resourceGroup.location `
--runtime dotnet-isolated `
--runtime-version "8" `
--https-only true `
--os-type Linux `
--zone-redundant false `
--disable-app-insights true
Yellow output: Creating deployment storage account container 'app-package-myappfunctions-7453307'... Red output: Cannot change the site myapp-functions to the App Service Plan ASP-myapp-b159 due to hosting constraints.
It seems that the new storage container is actually never created so the warning seems incorrect. The new App Service Plan is created but it seems to go away automatically after a while.
Is your feature request related to a problem? Please describe.
When users of my script see errors when a resource already exists it creates unnecessary uncertainty since az is designed to be idempotent.
The inconsistent output error severity makes it unnecessarily difficult to read the console output.
Describe the solution you'd like I mostly want it to be consistent and not be an error. Warning or information is fine.
Thank you for opening this issue, we will look into it.
Here are some similar issues that might help you. Please check if they can solve your problem.
- #26770
Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)
After having evaluated carefully the pros and cons of leaving the current behavior as-is or changing it in the way you're requesting, we have decided to leave it as it is now. The main reason for having taken that decision is that such change would be considered a breaking change, and it would indeed break all existing automation that relies on a logic like the following:
1. tries to create the resource
2. if fails,, do something
because the failure logic would no longer execute.
Reference:
- https://github.com/azure/azure-cli/issues/26770#issuecomment-2416030235
Powered by issue-sentinel
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kamperiadis, @amamounelsayed, @khkh-ms.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @chen-karen, @chandanrr, @cheathamb36.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp, @yutanglin16.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kamperiadis, @amamounelsayed, @khkh-ms.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @chen-karen, @chandanrr, @cheathamb36.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp, @yutanglin16.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kamperiadis, @amamounelsayed, @khkh-ms.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @chen-karen, @chandanrr, @cheathamb36.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp, @yutanglin16.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kamperiadis, @amamounelsayed, @khkh-ms.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @chen-karen, @chandanrr, @cheathamb36.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp, @yutanglin16.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kamperiadis, @amamounelsayed, @khkh-ms.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @chen-karen, @chandanrr, @cheathamb36.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp, @yutanglin16.
Hi @gabbsmo , thanks for raising the issue. The text colour is fully controlled by the terminal you’re using. Based on my analysis, the Errors/Warnings are being output correctly—any differences in colour rendering are due to your local environment. I’m currently looking into the inconsistent create behaviour and will provide an update once I have more details.
Thank you @MaddyMicrosoft. I am using the Terminal app in Windows 11 with PowerShell 7.
@gabbsmo I have confirmed the way warnings and errors are emitted is consistent across the CLI — I tested various commands and modules and none of them emit ANSI color codes on stderr. The CLI uniformly ships plain text; all color rendering you observe is applied by PowerShell 7's host. PS7 paints stderr red by default (so ERROR: lines appear red) and yellow when it interprets a line as a warning record, but that detection can vary depending on how the line arrives — which is why some WARNING: lines render yellow and others white in the same session. So: • The severity the CLI uses is consistent (warning for patch/reuse, error for refuse). • The visual color comes from PS7's stderr rendering, not the CLI. • The error from az keyvault create when the vault already exists is intentional — it was added in #18520 to prevent a destructive mutation bug where re-running the command was silently overwriting existing access policies. • The broader idempotency inconsistency is a known issue tracked in #7613. I'll flag it with the team to see if it can be prioritised.
If you'd like the color rendering itself looked at more closely, it'd suggest raising on the PowerShell repo since the colorization is happening on that side. Given the color behaviour is on the PowerShell side and the idempotency inconsistency is already tracked in #7613, I'm going to close this issue. Please feel free to reopen or comment if you'd like to discuss further.