WebJob Deployment from 4.7 Framework to 7.0 Core

Olivier Cochet 0 Reputation points
2023-11-13T13:41:32.4833333+00:00

I am migrating my code towards 7.0 .Net

My previous Webjobs has compiled correctly but my deployment through Azure Devops pipeline is failing.

It seems i have to change something about the application pool in my azure resource app service.

Would you guide through it or may i have to create a brand new app service

2023-11-13T13:19:58.3823566Z ##[error]Error: Error Code: ERROR_APPPOOL_VERSION_MISMATCH
More Information: The application pool that you are trying to use has the 'managedRuntimeVersion' property set to 'v4.0'. This application requires 'v7.0'.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_APPPOOL_VERSION_MISMATCH.  Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_APPPOOL_VERSION_MISMATCH.
Error count: 1.
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,647 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,407 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Grmacjon-MSFT 17,456 Reputation points
    2023-11-15T03:17:23.0833333+00:00

    Hi @Olivier Cochet the error message you shared means that your Azure App Service application requires the .NET runtime version 7.0 (v7.0), but the application pool in your Azure App Service is currently configured for the .NET runtime version 4.0 (v4.0). To resolve this issue, you have a few options:

    1. Update Existing App Service:

    You can update the existing App Service to use the correct .NET runtime version.

    Azure Portal:

    • Navigate to the Azure Portal.
    • Go to your App Service.
    • In the left-hand menu, click on "Configuration."
    • In the "General settings" section, look for the ".NET version" setting.
    • Change the setting to ".NET 7 (LTS)" or the appropriate version.

    Azure CLI:

    • Use the Azure CLI to update the .NET runtime version:
    az webapp config set --name <your-app-name> --resource-group <your-resource-group> --net-framework-version "v7.0"
    

    Azure DevOps Pipeline:

    • If you're deploying through Azure DevOps, make sure your release pipeline sets the correct .NET version during deployment.
    1. Create a New App Service:

    If updating the existing App Service is not feasible, you might consider creating a new App Service with the desired .NET version:

    Azure Portal:

    • Create a new App Service.
    • During the creation process, specify the correct .NET version.

    Azure CLI:

    Use the Azure CLI to create a new App Service:

    az webapp create --name <new-app-name> --resource-group <your-resource-group> --plan <your-app-service-plan> --runtime "DOTNET|7.0"
    

    Hope that helps.

    Grace

    0 comments No comments

  2. Olivier Cochet 0 Reputation points
    2023-11-16T15:46:37.49+00:00

    @Grmacjon-MSFT

    Hello, Although your input did not solve my problem, it gave me clues to go further in my analysis.

    Here is the facts.

    We have a pipeline using Devops Task "App Service Deploy", on the other end for test purpose, we also use the publish from VisualStudio.

    In the publish manner we set SelfContained to true and my API works fine (if i don't i have the same problem).

    Further in the analysis i see that :

    • When the API does not find the runtime i have this in the runtimeconfig.json
    {
      "runtimeOptions": {
        "tfm": "net7.0",
        "frameworks": [
          {
            "name": "Microsoft.NETCore.App",
            "version": "7.0.0"
          },
          {
            "name": "Microsoft.WindowsDesktop.App",
            "version": "7.0.0"
          },
          {
            "name": "Microsoft.AspNetCore.App",
            "version": "7.0.0"
          }
        ],
        "configProperties": {
          "System.GC.Server": true,
          "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
          "System.Reflection.NullabilityInfoContext.IsSupported": true,
          "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
        }
      }
    }
    
    • When the API does work fine we have the right value.
    {
      "runtimeOptions": {
        "tfm": "net7.0",
        "frameworks": [
          {
            "name": "Microsoft.NETCore.App",
            "version": "7.0.13"
          },
          {
            "name": "Microsoft.WindowsDesktop.App",
            "version": "7.0.13"
          },
          {
            "name": "Microsoft.AspNetCore.App",
            "version": "7.0.13"
          }
        ],
        "configProperties": {
          "System.GC.Server": true,
          "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
          "System.Reflection.NullabilityInfoContext.IsSupported": true,
          "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
        }
      }
    }
    

    IUser's image

    I am still working on the way to correctly set the value on my Azure Devops pipeline


  3. Olivier Cochet 0 Reputation points
    2023-11-21T08:28:38.43+00:00

    It has been solved. During the update the assistant asks me to declare net7.0-windows cause there was a dependency that i got rid of.

    As soon as i declared net7.0 in all sub projects and main project the deploy went fine.

    What is odd is that Windows was installed on the webapp. it should have been ok.

    Maybe by getting the project portable, it was up to the system to find the actual version of dotnet.

    0 comments No comments

  4. Olivier Cochet 0 Reputation points
    2023-11-21T08:30:34.74+00:00

    It has been solved. During the update the assistant asks me to declare net7.0-windows cause there was a dependency that i got rid of.

    As soon as i declared net7.0 in all sub projects and main project the deploy went fine.

    What is odd is that Windows was installed on the webapp. it should have been ok.

    Maybe by getting the project portable, it was up to the system to find the actual version of dotnet.

    0 comments No comments