Share via

JS Azure Function ServiceUnavailable error

mehr 0 Reputation points
2024-06-27T05:28:30.9766667+00:00

I have built a very simple TS/JS Azure function deployed using Terraform by GitHub Actions and code uploaded az ZIP to the blob connected to the function using WEBSITE_RUN_FROM_PACKAGE.

Now the function app doesn't show any functions under the app with the error

We were not able to load some functions in the list due to errors. Refresh the page to try again. See details

And the details says:

Encountered an error (ServiceUnavailable) from host runtime.

No logs are being logged in Application Insight.

The zip file uploaded on the blob contains:

host.json, package.json, node_modules (--prune ed), dist and here is the content of package.json:

{
  "name": "mem",
  "version": "1.0.0",
  "description": "",
  "main": "dist/src/functions/*.js",
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "clean": "rimraf dist",
    "prestart": "npm run clean && npm run build",
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "@azure/functions": "^4.0.0"
  },
  "devDependencies": {
    "azure-functions-core-tools": "^4.x",
    "@types/node": "18.x",
    "typescript": "^4.0.0",
    "rimraf": "^5.0.0"
  }
}

Where should I start looking for the problem?

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Achraf Ben Alaya 1,396 Reputation points MVP
    2026-04-02T21:41:11.02+00:00

    This happens because Azure Functions can’t find your function entry points your "main": "dist/src/functions/*.js" is invalid (wildcards aren’t supported), so the runtime fails to load anything.

    Fix it by pointing to a single compiled entry file (e.g. "main": "dist/src/index.js") and ensure your functions are properly registered/exported from there.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

Your answer

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