Azure Static Web App function API refusing connection from web app

Beau 0 Reputation points

I have a Blazor WASM app deployed to an Azure Static Web app with a managed .NET 8 isolated Azure Function API. When calling the API directly from Postman using the auto-generated web app URL + the API route I receive the expected response and can see a log in Application Insights. However when I call the same endpoint from within the deployed WASM application I receive an net::ERR_CONNECTION_REFUSED response and a request isn't recorded in Application Insights. I have confirmed that this is functioning as expected locally.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,185 questions
Microsoft Technologies based on the .NET software framework.
3,323 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,371 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
750 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    Comments have been turned off. Learn more

  2. Pinaki Ghatak 2,240 Reputation points Microsoft Employee

    Hello Beau

    There are two things you can check.

    1. This could be a CORS issue. Use online tools like to check if your API supports CORS requests. This tool allows you to send CORS requests to a remote server or a test server and provides feedback on whether CORS is functioning as expected. Here’s how you can use it: Visit Enter your Azure Function API URL (e.g., the auto-generated web app URL + API route). Click the “Send CORS Request” button. Inspect the response to see if the necessary CORS headers are present.
    2. The CORS can be set up in your host.json.
    3. Check the logs of the Azure function and see if the requests are accepted in the first place. Are you also using the function keys in your request?
    0 comments No comments

  3. brtrach-MSFT 15,091 Reputation points Microsoft Employee

    @Beau I agree with Pinaki that you should start with CORS.

    If you have confirmed that CORS is not the issue, you can check the logs of your Azure Function app to see if there are any errors or exceptions being thrown. To do this, you can follow these steps:

    1. Open your Azure Function app in the Azure portal.
    2. Go to the "Functions" tab and select the function that you are calling from your Blazor WASM app.
    3. Click on the "Logs" tab to view the logs for that function.
    4. Try calling the function from your Blazor WASM app again and see if any errors or exceptions are logged.

    If you see any errors or exceptions in the logs, you can use that information to troubleshoot the issue further. For example, if you see an error related to authentication or authorization, you may need to update the authentication settings for your Azure Function app.

    You can also try debugging your Blazor WASM app to see if there are any issues with the way you are calling the API. To do this, you can use the browser's developer tools to inspect the network requests being made by your app. You can also add logging statements to your Blazor WASM app to help you identify any issues with the way you are calling the API.

    Let us know the outcomes of the above. We look forward to your reply.

    0 comments No comments