The secret value should not be hardcoded in the code. Instead Key vault has to be used and that's the idea behind using key vault.
Please see how web apps can access secret value from the key vault here:
https://learn.microsoft.com/en-us/azure/key-vault/general/tutorial-net-create-vault-azure-web-app
https://www.loginradius.com/blog/async/guest-post/using-azure-key-vault-with-an-azure-web-app-in-c-sharp/
----------
Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav