After updating or changing the User Secrets we need to restart or recreate the revision.

My Secrets:

Reading Secret Key:
public IActionResult Index()
{
ViewBag.MyKey= Environment.GetEnvironmentVariable("mykey");
return View();
}
Make sure the name of the key must be same as the local Secret name.
Even if you have secrets created in the Secrets section of the Azure Container App, you can see the Environment variables in Container Section is unavailable.

For the secrets to work, we need to map the secrets into the Environment variables.

Create new Revision
Click on the container image => Create Environment variables with mapping to the existing secrets =>Save => Refresh

Every time you make changes to the secrets in portal, If you don`t have the revision we need to create it or restart the existing Revision.
Use the below command to restart the revision.
az containerapp revision restart --resource-group "yourRG" --name "containerappname" --revision "revisionname"
