Troubleshooting

This section explains how to troubleshoot the development environment.

Cannot run locally

Error Message: _There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid._

Fix: Start the _Azurite Blob Service_ before the execution.

Error Message: _Value cannot be null. (Parameter 'provider')._

Fix: Use a different version of Azure Functions Core Tools. The following can be executed in a Terminal window: _"npm i -g azure-functions-core-tools@4.0.5095 --unsafe-perm true"_

Cannot run local configuration

If _Run and Debug_ on a configuration displays an error message saying that it is not valid.

Fix: Restart VS Code. This can happen after a restart of the computer.

Debugger not working

Fix: Start the _Azurite Blob Service_ before starting the debugger.

Node.js can not start local service

Error Message: _A function can only be registered during app startup.

Fix: Since 2024.11 then a "main" field needs to be set in the "package.json" file. This should automatically be done when updating the framework. If this failed for an unknown reason, then add the following to the "package.json" file:

```json
"main": "dist/main.js",
```

Error Message: _Worker was unable to load function ...: 'Error: Cannot find module '...'_

Fix: Make sure that relative imports are used.

Example:

```typescript
import { ... } from "generated/models/my-class"
```

should be:

```typescript
import { ... } from "../generated/models/my-class"
```

Error when serializing objects to Xml in Java

Error Message: _MessageBodyWriter not found for media type=application/xml_

Fix: See documentation under "Code Examples -> Serialization".

Compilation error in Java for missing dependencies

For example, when a new Java project is created in some cases the Java extension in VS Code doesn't understand where to find the new dependencies.

Fix: First, restart VS Code. If that doesn't help, the following command can be executed from the Command Palette: "Java: Clean Java Language Server Workspace".

Cannot execute API calls locally

If the API call throws the following exception: _API client has not been initialized_

Fix: Verify the following:

  1. The "api" feature must be enabled in the manifest.
  2. Make sure that a "baas.env" file exists in the root of your workspace folder. If not, make sure that you have opened the project through the workspace file and not through the folder.
  3. Check that the "Enable Local Environment" setting is enabled for BaaS in the VS Code settings.

After launching a debug session then execution quits without any message

Fix: Disable the _Azure Functions: Stop Func Task Post Debug_ setting in VS Code.

Java project is not working in VS Code

If there are compilation problems because dependencies can not be found, it could be that the Java Language Server is not working.

Fix 1: Open the Command Palette in VS Code and run this command: "Java: Clean Java Language Server Workspace".

Fix 2: Make sure that your _JAVA_HOME_ environment variable points to a JDK 17. Example: _C:\Program Files\Amazon Corretto\jdk17.0.10_7_

Java project error while debugging variables

Error Message:

_Cannot evaluate because of java.lang.IllegalStateException: Project ... cannot be found.._

Fix: Make sure that the "artifactId" in the "pom.xml" file matches the "projectName" in the "launch.json", which can be found in the ".vscode" folder.

Additionally, the following is usually needed:

Open the Command Palette in VS Code and run this command: "Java: Clean Java Language Server Workspace".

Cannot run locally (security restriction)

When you try to start the debugger and run Azure functions on your local machine and you get an error that says:


 _...You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies..._

Fix: Open PowerShell in admin mode. Enter the following command: _$ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned_

Update of BaaS Extension fails in MacOS

When the BaaS Extension notifies there's an available update of the BaaS Extension and when the update is executed, the install fails with "/bin/ksh: code: not found".

The probable cause is that _Visual Studio Code.app_ is launched from the Download folder. Drag and drop the _Visual Studio Code.app_ file from Download to Applications folder as stated in the Microsoft installation instruction.

Launch Visual Studio and run the <F1> "Shell Command: Install 'code' command from PATH" command.

If a security error dialog appears, run the uninstall command before calling install again. Launch Visual Studio and run <F1> "Shell Command: Uninstall 'code' command from PATH" command, then run <F1> 'Shell Command: Install 'code' command in PATH'

Generating code from OpenAPI files

OpenAPI document needs property servers with either URL or basePath defined, which will be prefixed to all generated apis. When it's missing, you might get the error: Invalid openapi servers property. One of \"url\" or \"basePath\" variables required with prefix /api

See the section Manual/REST Service.

Java Language Server requires a JDK 17+ to launch itself.

If java cannot be found on your system, check your JAVA_HOME system environment variable. If it still doesn't work, you can map a java version to a path, by configurating your profile settings "java.configuration.runtimes".

name: Java Execution Environment name. Must be unique.

path: should be the JDK installation directory, not the Java bin path. On Windows, backslashes must be escaped.

Example, something like this:

```json
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-17",
            "path": "C:\\Program Files\\Amazon Corretto\\jdk17"
        }
    ],
```

First deploy of the first service is not working

The first time a deployment happens, an environment is configured behind the scene. In some cases, the number of concurrent execution must be increased. This can take up to a few hours. During this time, a message saying that concurrent executions is too low might appear.

Fix: Try again after an hour.

Tenant has been throttled due to exceeding the rate limit.

Each customer has an amount of daily execution time. When the execution time of the tenant has exceeded the rate limit, the tenant is throttled and all the services are disabled. The amount of available execution time is controlled by the BaaS license. See the Documentation/Manual/Usage limits guide for more information.

Fix: Try again the next day (the execution time of the tenant will reset again the next day).

Fix 2: Upgrade the BaaS license to get more daily execution time.

Failed to load API definition in Swagger UI

If the Swagger UI fails to load the API definition, the rate limit of the tenant could have been reached.

Fix: See "Tenant has been throttled due to exceeding the rate limit" section above.

Getting 403 Forbidden when accessing a REST api

If the REST call returns a 403 with the message "The role definition for the function cannot be assumed by Lambda.", the rate limit of the tenant has been reached.

Fix: See the "Tenant has been throttled due to exceeding the rate limit" section above.

Getting an Error: connect ECONNREFUSED when using Postman Client

If the REST Calls from Postman Client returns an "connect ECONNREFUSED", the "Enable Session Provider Server" BaaS setting is probably disabled.

Fix: Run command F1 "BaaS: Open Settings" and ensure that "Enable Session Provider Server" is enabled.