JetBrains / azure-tools-for-intellij

Azure Toolkit for JetBrains Rider.
MIT License
48 stars 10 forks source link

Unable to launch Azure Functions locally in Rider 2024.2 + plugin v4.0.0 #881

Closed SergeySalinAtDataart closed 1 month ago

SergeySalinAtDataart commented 1 month ago

Hello, today I have updated Rider to version 2024.2 and it updated Azure Toolkit plugin to version 4.0.0. After that, I was unable to launch my project with Azure functons because Rider marked previous configurations as broken with a title: This configuration cannot be edited and message on the bottom panel: Run Configuration Error: Broken configuration due to unavailable plugin or invalid configuration data.

I have tried to create a new Azure - Run Function App configuration but it now asks me for a launch profile and I have no idea where to get this launch profile. Apparently, Rider doesn't know too and just says "(Unknown)": image

And without this launch profile functions won't start. If I ignore the warning about missing launch profile and press "Continue Anyway" it successfully builds the project but a popup with the following error appears: "Can't run Azure Functions host. Unable to create .NET executable"

In the previous Rider version with Azure Toolkit v. 3.5 everything still works just fine

rafaelldi commented 1 month ago

Hello. This is because your project is probably missing the launchSettings.json file. I will check if this requirement can be relaxed. As a workaround, you can add this file with, for example, such content.

{
  "profiles": {
    "FunctionApp1": {
      "commandName": "Project",
      "commandLineArgs": "--port 7217",
      "launchBrowser": false
    }
  }
}
wahyuen commented 1 month ago

Exact same errors as @SergeySalinAtDataart , upon upgrading to 2024.2 I can now no longer run any of the function configurations that I was able to prior to the upgrade :/

image

rafaelldi commented 1 month ago

@wahyuen Yes, due to a major release we have some breaking changes and the old run configurations will no longer work.

SergeySalinAtDataart commented 1 month ago

Hello, @rafaelldi I have added the file that you've mentioned but it didn't help: image The launch profile is still (Unknown) and there's nothing else in the dropdown

rafaelldi commented 1 month ago

launchSettings.json should be in the Properties folder. Here is an example:

image

SergeySalinAtDataart commented 1 month ago

@rafaelldi thanks! This actually helped to get a working configuration, but I still cannot launch functions in new Rider - after build and launch my console window is filled with the following error:

[2024-08-16T08:36:56.171Z] Error building configuration in an external startup class.
[2024-08-16T08:36:56.172Z] Error building configuration in an external startup class. Nova.Samples.Functions: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
[2024-08-16T08:36:57.483Z] A host error has occurred during startup operation 'c69fb05c-0c23-466d-8545-6fe5bc29025d'.
[2024-08-16T08:36:57.484Z] Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. Nova.Samples.Functions: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

I have tried to explicitly install the package using NuGet but with no success In previous version of Rider functions are launched without any problems.

rafaelldi commented 1 month ago

Could you please check if this is happening from the Rider or the func CLI? Here in the Run tool window should be the path to the func util. Could you run the same command as in Run tool window func.exe host start --pause-on-error --port 7070 manually from the project folder (where you have the host.json file).

image

SergeySalinAtDataart commented 1 month ago

I've picked the following command from the Run window: C:\Users\SergeyS\.AzureToolsForIntelliJ\AzureFunctionsCoreTools\v4\4.83.0\func.exe host start --pause-on-error --port 7070 It restored projects and launched the same versions of Azure stuff: image I have tried running the same command from the terminal but the result was the same -- it didn't start.

I've checked that the old Rider uses the following command in Run: C:\Users\SergeyS\.AzureToolsForIntelliJ\AzureFunctionsCoreTools\v0\4.84.0-inprocess\func.exe host start --pause-on-error

rafaelldi commented 1 month ago

Thank you, I will check. I've created a separate issue for that #885.

RubenDelange commented 1 month ago

I'm using Rider 2024.2.1 with Azure Toolkit for Rider 4.1.0 and having a Properties/launchSettings.json file. My old AzureFunctionsHost configurations are broken, as already discussed in this thread.

Adding a new AzureFunctionAppRun is possible, but it seems like the properties (ie. PROGRAM_PARAMETERS) are not properly visualised in the UI after saving them. (They are stored correctly in the workspace.xml file though)

Next to that, I can't run my Azure Function app locally via Rider because it breaks on a JSON comment character:

Unexpected JSON token at offset 2214: Expected quotation mark '"', but had '/' instead at path: $.Values.FUNCTIONS_WORKER_RUNTIME JSON input: .....onSchedule": "0 */1 * * * *", // every minute

Running the Function app via a terminal is possible (without the error above) and this is my current workaround via C:\Users\MyUser\.AzureToolsForIntelliJ\AzureFunctionsCoreTools\v4\4.83.0\func.exe host start --pause-on-error --port 7219

rafaelldi commented 1 month ago

@RubenDelange What do you mean that properties are not properly visualised in the UI?

I can't run my Azure Function app locally via Rider because it breaks on a JSON comment character

I've created a separate ticket for that #900

RubenDelange commented 1 month ago

@RubenDelange What do you mean that properties are not properly visualised in the UI?

When creating a new Azure - Run Function app: image

Hit OK, then reopen the Run/Debug configurations modal window: image

Function host arguments + Working directory values are not shown (but are present in the workspace.xml file)

rafaelldi commented 1 month ago

@RubenDelange Thank you, I will check

rafaelldi commented 1 month ago

@RubenDelange It's probably the same issue that the plugin doesn't allow comments in json files yet, so it throws an exception when deserializing local.settings.json. So that will be fixed too once this issue #900 is resolved.