Unable to test/run Azure Function form the portal

Henry Lam 45 Reputation points
2023-06-12T18:00:05.4066667+00:00

Getting this warning message when I am trying to test/run a function through the Azure portal.

Running your function in portal requires the app to explicitly accept requests from https://portal.azure.com. This is known as cross-origin resource sharing (CORS).

I've previously been able to test/run functions from the portal without any issues. Other users with the same permissions do not seem to have the same issue. I've tried with different browsers and computers and still getting the same issue.

Has anyone encountered this before and know how to fix the issue?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,990 questions
{count} votes

3 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 70,431 Reputation points
    2023-06-13T04:58:29.8433333+00:00

    @Henry Lam Thanks for reaching out.

    The issue should be observed for the same function app across to all users and not to specific user that login to azure portal.

    The warning message you are seeing indicates that the cross-origin resource sharing (CORS) policy for your Azure Function app needs to be updated to explicitly allow requests from https://portal.azure.com.

    Once you have updated the CORS policy, you should be able to test/run your function from the Azure portal without seeing the warning message.

    1. Open the Azure portal and navigate to your Function app.
    2. Under the "API" section, click on "CORS".
    3. In the "Allowed Origins" section, add https://portal.azure.com to the list of allowed origins.

    Click "Save" to save your changes.

    User's image

    If you continue to experience issues, you may need to clear your browser cache or try using a different browser to see if that resolves the issue.

    Feel free to get back to me if you need any assistance.

    Please "Accept Answer" if the answer is helpful so that it can help others in the community.

    27 people found this answer helpful.
    0 comments No comments

  2. Roman Gubanov 15 Reputation points Microsoft Employee
    2024-06-04T08:24:04.48+00:00

    None of the answers work. I have both https://portal.azure.com and https://ms.portal.azure.com in CORS and still getting the same error.

    4 people found this answer helpful.

  3. Andriy Bilous 11,421 Reputation points MVP
    2023-06-13T04:57:54.9966667+00:00

    Hello @Henry Lam

    "To prevent malicious code execution on the client, modern browsers block requests from web applications to resources running in a separate domain. Cross-origin resource sharing (CORS) lets an Access-Control-Allow-Origin header declare which origins are allowed to call endpoints on your function app."

    Refer - https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings#cors

    Configure function app's CORS list

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal#portal-3

    Answer in MSDN

    https://social.msdn.microsoft.com/Forums/en-US/ffb2067e-0846-450b-8665-0cd6199aad75/sudden-cors-client-error?forum=AzureFunctions#ffb2067e-0846-450b-8665-0cd6199aad75

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.