@Vishnuprasad KR As you have confirmed that your same code works on a different function app but when deployed to another azure function you receive 500 errors. In that case, looks like there might be some configuration in your local.setting.json that might not be created under the application setting in the azure function. You can compare the application setting with the working and non-working function app.
I will also suggest you to review Azure Functions diagnostics to find the root cause of the 500 error. Alternatively, you can also review your application insights logs for your function to know more about the full exception trace/error message that is causing 500 errors.