Need help on CORS and Collision errors when Function is deployed

SangeethaP 40 Reputation points
2023-10-06T07:45:59.3233333+00:00

I am completely new to Azure cloud. When I deployed my Azure Function in to Function app using VS code, in the Azure portal, I am seeing the error says that "System.InvalidOperationException : A collision for Host ID 'functionAppName' was detected in the configured storage account."

When I try to run the function using the option Code Test/Run, the Run button is disabled with the error message "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 have no idea of what these errors all about and how to fix these errors, since working with Azure is completely new to me.

Kindly help to fix these issues and make the function work properly.

Error 1:

AZFD004
Diagnostic event
Error code
AZFD004
Level
Error
Message
A collision for Host ID 'functionAppName' was detected in the configured storage account. For more information, see URL.
Details
System.InvalidOperationException : A collision for Host ID 'functionAppName' was detected in the configured storage account. For more information, see URL.
Hit count
23
Timestamp
October 6, 2023 at 12:30:18 AM GMT+5:30
Help link

Error 2:

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). Click here to add https://portal.azure.com to the allowed origin configuration.
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,678 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,016 Reputation points
    2023-10-06T09:00:10.79+00:00

    @SangeethaP Thanks for reaching out.

    For your first error. This error message indicates that there is a collision for Host ID 'functionAppName' in the configured storage account. This error usually occurs when you have the same host ID assigned to multiple function apps or slots, which also share the same storage account.

    To resolve this issue, you can try the following options:

    • Connect each function app or slot in the collision to a different storage account by changing the AzureWebJobsStorage application setting or slot setting. You need to the application setting of your function app. For more details, please refer to this document on how to configure any application setting.
    • Rename your function apps to a name that has fewer than 32 characters. When app names have fewer than 32 characters, unique host IDs can be generated for each app, which removes the collision.

    For your second error you need to configure the CORS and you can navigate to your function app and under the API section you will see the CORS option. Please add the URL for which you are getting the error and click on Save.

    User's image

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful