0

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?

Ramesh
  • 1,041
  • 15
  • 39

1 Answers1

1

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

Rukmini
  • 6,015
  • 2
  • 4
  • 14
  • I tried with `MyConnectionStrings_MyContext` and `MyConnectionStrings__MyContext` but no use. – Ramesh Mar 10 '22 at 09:22
  • @Ramesh Are you able to update the environment variable? – Rukmini Mar 10 '22 at 10:29
  • Yes, I can add but those env variables are not effective where as other env variables without `.` are effective. – Ramesh Mar 10 '22 at 10:42
  • @Ramesh, Could you please follow the [document](https://www.mihajakovac.com/set-environment-variables-to-azure-container-app/) and try!! – Rukmini Mar 10 '22 at 11:10
  • Exactly... but no luck for me. The same image with `__` environment variables is working in the case of `Azure Web Apps for Containers`. – Ramesh Mar 10 '22 at 11:40