Search code examples
azurekubernetesazure-container-apps

How to add indepth environment variables in Azure Container Apps


I am trying to add my context as an environment variable in Azure Container App like below but it throws an error.

az containerapp update -n MyContainerapp -g MyResourceGroup -v ConnectionStrings:MyContext=secretref:mycontextsecretkey

Invalid value: "ConnectionStrings:MyContext": Invalid Environment Variable Name

I tried with ConnectionStrings__MyContext but the Asp.Net Core app does not recognize it.

How can I add this?


Solution

  • This error Invalid value: "ConnectionStrings:MyContext": Invalid Environment Variable Name indicates that environment variable you are trying to define is unsupported.

    Instead of using "ConnectionStrings:MyContext", use MyConnectionStrings_MyContext as your environment variable.

    You can use the below command,

    az containerapp update -n MyContainerapp -g MyResourceGroup -v MyConnectionStrings_MyContext=secretref:mycontextsecretkey
    

    Reference : Set Environment variables to Azure Container App | Miha Jakovac