The issue is similar to this https://stackoverflow.com/questions/79221267/azure-app-service-deployment-fails-with-system-text-json
As suggested, the deployment by default is using the latest sdk so to specify explicit version a global.json needs to be added.