I have an azure web application in which I want to update a webjob project to target framework .net 7 but leave the web site at .net 4.7.1 due to legacy constraints on the project.
Is it possible to deploy webjobs with different target frameworks than the web site? If not, is there a better way to approach this problem?
I tried updating the webjob project to .net 7 and deploying, but I the following error when I deploy a webjob to azure that has a different target framework (.net 7.0) than the website (4.7.1).
[12/12/2023 01:07:43 > 0f00b5: ERR ] You must install or update .NET to run this application. [12/12/2023 01:07:43 > 0f00b5: ERR ] [12/12/2023 01:07:43 > 0f00b5: ERR ] App: C:\local\Temp\jobs\continuous\WebJobs\2vgixjvc.b00\WebJobs.exe [12/12/2023 01:07:43 > 0f00b5: ERR ] Architecture: x64 [12/12/2023 01:07:43 > 0f00b5: ERR ] Framework: 'Microsoft.WindowsDesktop.App', version '7.0.0' (x64) [12/12/2023 01:07:43 > 0f00b5: ERR ] .NET location: C:\Program Files\dotnet
Changing the Web App configuration to .net 7 does not seem to make a difference.
If you want to deploy to any other Version of .NET other than the existing website, Follow the below steps.
If you get this error with Framework website hosted in .Net Core,try to install the `ASP.NET Core 7.0 Runtime extension.
As per this MSDoc,
Migrating from .NET Framework to .NET Core requires manual work.
.Net Core
requiresappsettings.json
file to add the Connection String (related to WebJob).In.Net Framework
app your connection strings are stored inApp.config
file.Even
.csproj
in framework app contains additional settings which are not required for Core Apps, even those have to be edited.AFAIK,It is better to create a separate Core Application and add the existing Functions/Jobs to it.
Update
Publish
=>Add a publish profile
=>Azure
=>Azure WebJobs