You can try with this approach, if you are upgrading you function app to .Net 8 in-process model.
If you are running locally make sure that you have those environment variables available in your json file. The same applicable for the azure environment as well. Also make sure that you have updated your package references.
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "FUNCTIONS_INPROC_NET8_ENABLED": 1, "FUNCTIONS_EXTENSION_VERSION": "~4" }