Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
330 stars 56 forks source link

net7.0 not supported for static web app functions? #996

Closed philvessey closed 1 year ago

philvessey commented 1 year ago

Describe the bug

Deploying throws the following error for the functions: The function language version detected is unsupported or invalid. The following dotnet language versions are valid: 3.1, 6.0. If you are not using Azure Functions, you can skip this check by removing the 'api_location' input from the workflow file.

A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Change net6.0 to net7.0

Expected behavior net7.0 should be supported for static web apps - it is for standard function apps.

vivekjilla commented 1 year ago

@philvessey can you please check if you're providing apiRuntime in staticwebapp.config.json. If so, it should be set to dotnet-isolated:7.0. More details at https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#selecting-the-api-language-runtime-version

If not, please check if you're creating the function app project as an isolated worker process project. More details at : https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#net-isolated-worker-process-project A sample dotnet7 isolated app csproj: https://github.com/vivekjilla/blazor-sample/blob/main/ApiIsolated/ApiIsolated.csproj

philvessey commented 1 year ago

It needs to be isolated for net 7.0 with static web apps? I ask as a standard functions app on azure is working fine on net7.0 which isn't isolated.

philvessey commented 1 year ago

https://github.com/Azure/static-web-apps/issues/974 this issue suggests coming soon - guessing not supported yet.

thomasgauvin commented 1 year ago

@philvessey can you provide any sample projects of your function app running on .NET 7 in-process? My understanding from these Azure Functions docs is that .NET 7 is only supported as an isolated process, though perhaps that isn't made clear when creating a Function App. https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library?tabs=v2%2Ccmd#supported-versions, https://azure.microsoft.com/en-ca/updates/generally-available-functions-now-supports-net-7-in-an-isolated-worker-process/

Regarding whether SWA supports .NET 7, we announced that the support for .NET 7 is GA here https://azure.microsoft.com/en-us/updates/generally-available-azure-static-web-apps-now-fully-supports-net-7/

philvessey commented 1 year ago

It sounds like I need to go to isolated so i'm in the process of updating my code to that - will report back if I have any further issues but I have quite a few functions to update so it may be a few days.

philvessey commented 1 year ago

Working fine with isolated so ill close.

thomasgauvin commented 1 year ago

Glad to hear @philvessey, thanks for the feedback, we're working on improving our getting started docs for .NET 7 as well

Ankurakvaliya009 commented 1 year ago

I updated .net6 to .net7 in azure function project i got this error in github pipeline

image

philvessey commented 1 year ago

I updated .net6 to .net7 in azure function project i got this error in github pipeline

image

See above - your functions need to run in dotnet-isolated mode - will work fine once converted.

Ankurakvaliya009 commented 1 year ago

@philvessey

I already set "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"in local.settings.json file still it's not working

philvessey commented 1 year ago

As referenced there are multiple steps needed. New nuget packages, a program.cs file and likely signature changes to your functions to use the new packages. See https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#net-isolated-worker-process-project

philvessey commented 1 year ago

Also if you look at the API project here https://github.com/staticwebdev/blazor-starter you will see what a basic isolated API looks like and you can go from there 👍

Ankurakvaliya009 commented 1 year ago

@philvessey

I did all the step but still i am getting the same error, do i need to change anything in azure server?

image

philvessey commented 1 year ago

No changes needed on the server - do you have your project up anywhere to have a look at?

Izzmo commented 1 year ago

I changed this to .NET 7 and dotnet-isolated and was able to get the Azure Pipelines task to recognize and push it, but then Azure wouldn't let the function run. Getting 500 errors.

philvessey commented 1 year ago

500 server error is what you will get if there is an error in your functions code. Suggest wrapping everything in a try catch and outputting errors that way to narrow things down as that is what I did.

Izzmo commented 1 year ago

@philvessey I did, this is the error I get:

Did not find functions with language [dotnet-isolated]. 
Microsoft.Azure.WebJobs.Script.Utility.VerifyFunctionsMatchSpecifiedLanguage
philvessey commented 1 year ago

That looks like the old nugget packages - did you update to the Microsoft.Azure.Functions.Worker packages in csproj ?

Izzmo commented 1 year ago

@philvessey yes, I only have the two the v3 -> v4 migration article mentioned. It's kind of hard to debug the function with the static web app layer on top.

philvessey commented 1 year ago

Can you show some code or got the repo online?

Izzmo commented 1 year ago

@philvessey I ended up getting this to work by recreating the function from the .NET 7 template -- I must've missed something somewhere in converting over the function, possibly the routing attribute value.