Hi @Youc,
Use the below CLI command to verify that your environment variable is correctly configured.
az webapp config appsettings list --name AppName --resource-group RGName
- The above command will list all application settings configured for your App Service. Check for
SENDGRID_API_KEY
in the output. - Use the below line of code to retrieve the variable in your .NET application from the Environment Variable.
var sendGK= Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
If you want to retrieve the value using IConfiguration
, then you can use the below code
var sendGK= Configuration["SENDGRID_API_KEY"];
Another option to check if your setting is available is in KUDU AppSettings and environment variables.
URL - https://AppName.scm.azurewebsites.net
- If you are able to see the setting and still facing the issue. Try to set the value in KeyVault and retrieve it using KeyVault Reference in App Settings.
"SENDGRID_API_KEY": "@Microsoft.KeyVault(SecretUri=https://KVName.vault.azure.net/secrets/SecretName/)"
Hope this helps
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions, please reply back.