I'm not saying it was built with Azure Functions, but it was definitely built with Azure Functions.

swa emulator throwing “✖ Could not connect to “http://localhost:7071″. Is the server up and running?”?

This post was most recently updated on January 8th, 2024.

3 min read.

This article explains how to get around a weird quirk in Azure Static Web Apps local development story. Well – one of the quirks anyway. A real showstopper issue I ran into.

One, that isn’t even that serious – it’s just that the error message doesn’t help you at all.

But let’s take a step back – what was the issue we ran into, again?

Problem

When you’re running your project in Visual Studio Code, it fails to start and you have output somewhat like below in the console:

***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure.                           *
***********************************************************************

[run] dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
[run]   💡 Press "Ctrl + R" to restart.
[run] dotnet watch 🔧 Building...
[run]   Determining projects to restore...
[run]   All projects are up-to-date for restore.
[run]   ServiceHealthReader.Data -> C:\code\AdventureWorksSWA\ServiceHealthReader\ServiceHealthReader.Data\bin\Debug\net7.0\ServiceHealthReader.Data.dll
[run]   Shared -> C:\code\AdventureWorksSWA\ServiceHealthSite\Shared\bin\Debug\netstandard2.0\Shared.dll
[run]   Client -> C:\code\AdventureWorksSWA\ServiceHealthSite\Client\bin\Debug\net7.0\Client.dll
[run]   Client (Blazor output) -> C:\code\AdventureWorksSWA\ServiceHealthSite\Client\bin\Debug\net7.0\wwwroot
[swa]
[swa] Found configuration file:
[swa]   C:\code\AdventureWorksSWA\ServiceHealthSite\Client\staticwebapp.config.json
[swa]
[swa] - Waiting for http://localhost:7071 to be ready
[run] dotnet watch 🚀 Started
[run] info: Microsoft.Hosting.Lifetime[14]
[run]       Now listening on: http://localhost:5000
[run] info: Microsoft.Hosting.Lifetime[0]
[run]       Application started. Press Ctrl+C to shut down.
[run] info: Microsoft.Hosting.Lifetime[0]
[run]       Hosting environment: Development
[run] info: Microsoft.Hosting.Lifetime[0]
[run]       Content root path: C:\code\AdventureWorksSWA\ServiceHealthSite\Client
[swa] ✖ Waiting for http://localhost:7071 to be ready
[swa] ✖ Could not connect to "http://localhost:7071". Is the server up and running?
[swa] node "C:\Users\jmcclane\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\msha\server.js" exited with code 0
--> Sending SIGTERM to other processes..
[run] cd "C:\code\AdventureWorksSWA\ServiceHealthSite\Client" && dotnet watch run exited with code 1
✖ SWA emulator stoped because the --run command exited with code 1.
PS C:\code\AdventureWorksSWA\ServiceHealthSite>

Alright. What do?

Solution

As ridiculous as this might seem, the issue might be caused by missing tooling for your Azure Functions project. You might have installed the right runtime, you might have the right SDK, you might’ve followed the guide to install the azure-functions-core-tools npm package and SWA CLI (static-web-apps-cli) – but you’re missing one step.

To get the SWA emulator in VS Code working…. You need to update the Azure Functions Core Tools. And chances are you’ve originally installed them for Visual Studio. And furthermore, chances are the easiest way to update them is using Visual Studio.

A bit odd – I know. Why would you need to update the Azure Functions Core Tools in Visual Studio, if you’re using Visual Studio Code?

Well – they’re separate development environments with very few dependencies. But they can still share build tooling, and you might still need to update it.

Anyway; here’s now to do just that.

Time needed: 10 minutes

How to update Azure Functions toolset (Azure Functions Core Tools) in Visual Studio?

  1. Open Visual Studio

    Maybe this wouldn’t even need to be said, but since you’ll (somewhat weirdly) need to update the Azure Functions Core Tooling in Visual Studio (maybe you could also just update a new executable? I’ll include a link in the bottom of the page, but this guide will follow the VS User Interface instead), we’ll need to start by opening up Visual Studio.

  2. Navigate to “Tools > Options”

    Top menu bar in Visual Studio has the “Tools”, option – select “Options” below it.

  3. Search for “func”

    Now we’ll need to search for your Azure Functions tools. You could search for something longer, but just typing “func” in the search box (CTRL+E) will do.

  4. Click “Check for updates”

    Now you should see an options window that’ll say something like “Manage Azure Functions toolsets and templates” (that’s “Azure Functions Core Tools” by another name). The window should have a small button for checking for updates – click it, and see what happens
    How to update Azure Functions toolset (Azure Functions Core Tools) in Visual Studio

  5. Wait for the download to finish

    Now there’s nothing left except for waiting. It should be done quite quickly though, and you can just get back to VS Code if you so wish. :)

Seeing how far the development experience in VS Code has come is nothing sort of impressive. But seeing how long way it sometimes still has to go (especially in regards to tooling), I’ll stick with Visual Studio still… 😅

References

If you don’t need to update, but rather need to install the Azure Functions Core Tools, you can do that here.

mm
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments