I've got a large-ish solution consisting of all .net8 code running in Rider on an Ubuntu / Mint Linux environment.
The API runs fine but the Function will not start. When I run them up I get the following message...
/home/{myname}/.AzureToolsForIntelliJ/AzureFunctionsCoreTools/v4/4.72.0/func host start --pause-on-error
dotnet sdk is required for dotnet based functions. Please install
Press any key to continue....
I have the .net8 SDK installed (else several other projects wouldn't be working) via the dotnet-install script.
What am I missing here?
Running dotnet --list-sdks gives me the following...
6.0.410 [/home/{myname}/.dotnet/sdk]
7.0.304 [/home/{myname}/.dotnet/sdk]
8.0.100 [/home/{myname}/.dotnet/sdk]
8.0.204 [/home/{myname}/.dotnet/sdk]
NOTE: Updated to latest net 8 version to see if that made any difference (It didn't).
Here's the *.csproj (If it helps)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<UserSecretsId>my-function</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.8.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
my host.json....
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
}
}
My local.settings.json...
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"APPLICATIONINSIGHTS_CONNECTION_STRING": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
I've got Docker containers running Azurite and Cosmos - The Cosmos one is working fine but the config on the Azurite container may be incorrect, but it feels like I'm not that far along the execution chain yet.
If I try to run it in Debug message I get a popup message in Rider which could be helpful...
Azure Functions host did not return isolated worker process id. Could not attach the debugger. Check the process output for more information.
The function was originally created in Visual Studio so I have tried to rule out any local environmental differences by creating an empty Function App in Rider to test with as well and I get exactly the same result with a basic Timer Trigger.
I have tried creating a shell script in the function root to run the following and executing it on the command line...
/home/keith/.AzureToolsForIntelliJ/AzureFunctionsCoreTools/v4/4.72.0/func host start --pause-on-error --verbose
This DOES work, which suggests something isn't right on the Rider side of things.
I believe I've found the root (pun not intended) cause to why Rider can't launch the functions.
If I execute on the command line with sudo rather than as myself then I get the same error.
sudo /home/{myname}/.AzureToolsForIntelliJ/AzureFunctionsCoreTools/v4/4.72.0/func host start --pause-on-error --verbose
[sudo] password for {myname}:
dotnet sdk is required for dotnet based functions. Please install https://microsoft.com/net
Press any key to continue....
In this context it doesn't work as the dotnet SDKs are installed for me in my user profile, using the dotnet-install.sh script.
Rider is clearly trying to execute the function with elevated privileges which, as I don't have the dotnet 8 SDK installed as a "machine wide" thing it, understandably fails.
sudo dotnet --list-sdks
sudo: dotnet: command not found
It seems that using the dotnet-install.sh script was the problem, or where it installs the SDKs by default. I installed the 6 and 8 SDK packages directly (this may not be a viable option on some distros - I came from Arch before and the AUR dotnet packages are not the most reliable)...
sudo apt-get install dotnet-sdk-6.0
sudo apt-get install dotnet-sdk-8.0
I then had to go through a bit of a weird step - After installing I had a local user copy installed in my home directory...
dotnet --list-sdks
8.0.203 [/home/{myname}/.dotet/sdk
I had 8.0.204 if running sudo and 8.0.203 on a different path when direct. I simply followed up with rm -rf ~/.dotnet and things returned to normal.
The outputs then look much more as expected:
sudo dotnet --list-sdks
6.0.421 [/usr/share/dotnet/sdk]
8.0.204 [/usr/share/dotnet/sdk]
dotnet --list-sdks
6.0.421 [/usr/share/dotnet/sdk]
8.0.204 [/usr/share/dotnet/sdk]
As a final cleanup I went through my .zshrc (or .bashrc depending on your shell of choice) and updated my PATH settings to point at the new paths and roots...
export PATH=$PATH:/usr/share/dotnet:/usr/share/dotnet/tools
export DOTNET_ROOT="/usr/share/dotnet"
After all the above my Function apps would then work but my APIs and Web projects wouldn't run anymore - It seems that they were looking for dotnet in /usr/lib/dotnet. I resolved this by symlinking the two paths together...
sudo ln -s /usr/share/dotnet /usr/lib/dotnet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With