Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied when running "func start" on .NET 8 in-process Function on Ubuntu 24.04 #3766

Closed
gabrielweyer opened this issue Jul 14, 2024 · 16 comments · Fixed by #3797
Closed
Assignees

Comments

@gabrielweyer
Copy link

  • .NET SDK: 8.0.107
  • Azure Function Core Tools: 4.0.5907
  • Ubuntu 24.04 (WSL but same issue was experienced using GitHub Actions)

When I run func start I get the below error:

Failed to start the in-process model host. An error occurred trying to start process '/usr/lib/azure-functions-core-tools-4/in-proc8/func' with working directory '/home/gabriel/MyProjFolder/bin/output'. Permission denied

Steps taken:

  1. func init MyProjFolder --worker-runtime dotnet
  2. cd MyProjFolder/
  3. func new --template "Http Trigger" --name MyHttpTrigger

I added FUNCTIONS_INPROC_NET8_ENABLED to local.settings.json:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "FUNCTIONS_INPROC_NET8_ENABLED": "1"
    }
}

I updated the project to target .NET 8:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.4.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

I'm able to run an in-process .NET 8 on Windows using the Azure Function Core Tools and on a Windows Function App.

@vfrrjq
Copy link

vfrrjq commented Jul 15, 2024

I have the same problem with the same versions of .NET and Azure Function Core Tools on my Mac.

Any luck funding solution to this anyone?

@mg-83
Copy link

mg-83 commented Jul 17, 2024

same here on Mac M1 with OSX, did anyone found any solutions

@qng5150
Copy link

qng5150 commented Jul 21, 2024

same here

@kshyju
Copy link
Member

kshyju commented Jul 22, 2024

Thanks @gabrielweyer We will investigate and share an update on this thread.
.

@mmowry-accuity
Copy link

Same here

@melvinvandenbout
Copy link

melvinvandenbout commented Aug 6, 2024

Same here with azure-functions-core-tools@4/4.0.5907.

Found a workaround which is working for me on MacOS:

chmod +x /usr/local/Cellar/azure-functions-core-tools@4/4.0.5907/in-proc8/func

I also updates this, not sure if this is required for the workaround:

<ItemGroup> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.4.1" /> </ItemGroup>

@RickDMyers
Copy link

Using chmod on in-proc8/func helped get past the permissions problem. However, my visual studio code fails to attach.

Now that it compiles and runs, how do you debug?

@joserhonFA
Copy link

joserhonFA commented Aug 15, 2024

@kshyju I saw your PR and I was able to fix the permissions problem as well using chmod +x, but the function never starts now. When I use func host start I don't get any error message it just exits execution:
Screenshot 2024-08-15 at 15 14 02

When I start the debugger (f5), it builds, but the nothing happens until I get a timeout error saying: "Failed to detect running Functions host within 60"seconds. You may want to adjust the "azureFunctions.pickProcessTimeout" setting."

This behavior is even happening with new functions I created to test .net8 using the in-process model

I have Sonoma 14.5 macOs and I'm using:

  • NET SDK: 8.0.303
  • Azure Function Core Tools: 4.0.5907

@essmd
Copy link

essmd commented Aug 16, 2024

@joserhonFA
i have exactly the same behavior. i got it to build successfully using chmod but i get exactly the same result and output. Like a simple build only.

  • .NET SDK 8.0.400 (latest)
  • Azure Function Core Tools (4.x, latest, clean download and installed)
  • MacBook Pro, M3, Sonoma

@Doo-Santi
Copy link

@joserhonFA i have exactly the same behavior. i got it to build successfully using chmod but i get exactly the same result and output. Like a simple build only.

  • .NET SDK 8.0.400 (latest)
  • Azure Function Core Tools (4.x, latest, clean download and installed)
  • MacBook Pro, M3, Sonoma

what worked for me was changing the local.settings.json file. Try having only
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}

@essmd
Copy link

essmd commented Aug 16, 2024

@Doo-Santi We want to run the functions as „in-process“ (dotnet). Using your settings will run the functions in „isolated“ mode (dotnet-isolated). I will try it anyway, to confirm it still works in isolated mode. Thanks!

@joserhonFA
Copy link

@joserhonFA i have exactly the same behavior. i got it to build successfully using chmod but i get exactly the same result and output. Like a simple build only.

  • .NET SDK 8.0.400 (latest)
  • Azure Function Core Tools (4.x, latest, clean download and installed)
  • MacBook Pro, M3, Sonoma

what worked for me was changing the local.settings.json file. Try having only { "IsEncrypted": false, "Values": { "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } }

This doesn't work. My function use the in-process model and I migrated to .net8 but still using the in-process model

@essmd
Copy link

essmd commented Aug 18, 2024

I got it working for me, its a very inconvenient workaround but it works. Maybe it helps anybody in the meantime.
I am using a MacBook Pro M3, Sonoma 14.3

  1. Checkout the source code for core tools.
  2. Build and publish the source (command has been copied from repo build script, but -f net8.0 was required to add due to an error)
  3. Use the manually built core tools cli to run your functions project
cd your-dev-folder
gh repo clone Azure/azure-functions-core-tools
cd azure-functions-core-tools

dotnet publish src/Azure.Functions.Cli/Azure.Functions.Cli.csproj -f net8.0 --runtime osx-arm64 --output /tmp/cli

cd your-functions-project-root
/tmp/cli/func start

@RickDMyers
Copy link

I tried the suggested workaround on my MacBook Pro M2 Somona 14.6.1

It worked, I started 'tmp/cli/func start' then used the command pallet to "Debug: Attach to .Net 5+ or .NET core process" and selected the running "func" application.

To make debugging easier, I updated my Visual Studio Code Configuration and set the "Azure Function Func Cli Path"
setting to "/tmp/cli/func". Visual Studio Debug with then work from "Run/Start Debugging" menu.

@despian
Copy link

despian commented Sep 20, 2024

I managed to get this working by re-signing the func binary using the codesign utility after updating the permissions.

First you need to generate a self-signed cert for code signing (details here) then:

cd /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.6280/in-proc8
chmod +x func
codesign --remove-signature func
codesign -s my-codesign-cert func

@kshyju the latest release doesn't seem to include this hotfix. When will it be released?

@RHangal
Copy link

RHangal commented Sep 23, 2024

I managed to get this working by re-signing the func binary using the codesign utility after updating the permissions.

First you need to generate a self-signed cert for code signing (details here) then:

cd /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.6280/in-proc8
chmod +x func
codesign --remove-signature func
codesign -s my-codesign-cert func

@kshyju the latest release doesn't seem to include this hotfix. When will it be released?

This solution worked for me, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment