Skip to content

Azure CLI "cors add" creates multiple entries of the same origin. #9778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
liron-navon opened this issue Jun 24, 2019 · 7 comments
Closed

Azure CLI "cors add" creates multiple entries of the same origin. #9778

liron-navon opened this issue Jun 24, 2019 · 7 comments
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Functions az functionapp Functions-cli needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Service Attention This issue is responsible by Azure service team.

Comments

@liron-navon
Copy link

liron-navon commented Jun 24, 2019

az feedback auto-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
Screenshot 2019-06-24 at 14 06 06

@ahmedelnably
Copy link
Contributor

Thanks for reporting that, we will take a look and fix it in a future release

@ahmedelnably ahmedelnably added this to the Backlog milestone Jun 24, 2019
@ahmedelnably ahmedelnably added the Functions az functionapp label Nov 5, 2019
@yonzhan yonzhan added the Service Attention This issue is responsible by Azure service team. label Dec 4, 2019
@ghost
Copy link

ghost commented Dec 4, 2019

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ ahmedelnably, @fabiocav

@jmulcahy-fiscaltec
Copy link

jmulcahy-fiscaltec commented Dec 5, 2019

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).

@LockTar
Copy link

LockTar commented Mar 12, 2020

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"
    }
}

@ShawnMcGough
Copy link

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

@yonzhan yonzhan removed this from the Backlog milestone Jul 30, 2020
@azure-sdk azure-sdk added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Sep 24, 2020
@SaurabhSharma-MSFT
Copy link
Member

@liron-navon Apologies for the delayed response. This GitHub issue has been open for quite some time. Could you please let us know if you still facing this issue and need assistance? Awaiting your reply.

@SaurabhSharma-MSFT SaurabhSharma-MSFT added the needs-author-feedback More information is needed from author to address the issue. label Feb 15, 2022
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Feb 22, 2022
@ghost
Copy link

ghost commented Feb 22, 2022

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@ghost ghost closed this as completed Mar 8, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Functions az functionapp Functions-cli needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

10 participants