az feedbackauto-generates most of the information requested below, as of CLI version 2.0.62
Describe the bug
Calling "az functionapp cors add" from the CI/CD pipeline creates a new cors entry every time, instead of checking if the entry already exists.
This is important since I use it in the pipelines which are called every time the git repo is updated.
To Reproduce
az functionapp cors add --resource-group $(ResourceGroupName) --name $(AppName) --allowed-origins $(allowedOrigins)
Expected behavior
If I call az functionapp cors add multiple time, it should just create a single entry of the origin and not multiple.
Environment summary
Azure pipeline
Additional context
Image from the azure dashboard

Thanks for reporting that, we will take a look and fix it in a future release
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ ahmedelnably, @fabiocav
Also had this issue. Only an issue after updating to latest version (can't say which version introduced the issue as I was previously 4 versions out of date).
Uggly workaround to check if origin is already set in PowerShell.
If not set, add it otherwise skip.
$FunctionAppName = "foo"
$ResourceGroupName = "bar"
# Configure CORS for Function App
Write-Host "Set CORS in function app"
$allowedOrigins = "https://dev.azure.com","https://localhost:3000"
foreach ($item in $allowedOrigins) {
Write-Host "Check if allowedorigin '$item' is already set"
$missesOrigin = az functionapp cors show --name "$FunctionAppName" --resource-group $ResourceGroupName --query "contains(to_string(length(allowedOrigins[?contains(@, '$item')])),'0')"
if ($missesOrigin -eq "true") {
Write-Host "Add allowedorigin '$item'"
az functionapp cors add -n "$FunctionAppName" --allowed-origins $item
}
else {
Write-Host "Allowedorigin '$item' already set"
}
}
Still an issue. I'm using a different workaround where I remove before adding. Seems to work fine since removing non-existing origins does not throw error or warning.
ex:
az functionapp cors remove --allowed-origins http://www.example.com
az functionapp cors add --allowed-origins http://www.example.com
Most helpful comment
Thanks for reporting that, we will take a look and fix it in a future release