0

Using the Azure CLI, I'm trying to add environment variables to an existing azure container with the following command:

$ az container create --resource-group toms-cool-group --name my-cool-container --image my-cool-container:v1 --environment-variables 'NumWords'='5' 'MinLength'='8'

But I get the following error back:

The updates on container group 'receipt-validator' are invalid. If you are going to update the os type, restart policy, network profile, CPU, memory or GPU resources for a container group, you must delete it first and then create a new one.

Any ideas?

Tom Irving
  • 10,041
  • 6
  • 47
  • 63
  • I'm also unable to update --dns-name-label as shown in the official documentation: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-update – Tom Irving Aug 10 '19 at 17:41

1 Answers1

1

Why not, you can add the environment variables to the existing azure container with the command as you showed:

az container create --resource-group toms-cool-group --name my-cool-container --image my-cool-container:v1 --environment-variables 'NumWords'='5' 'MinLength'='8'

As I see the error shows the group 'receipt-validator' is not the same as the group in the command toms-cool-group. Maybe it's the mistake you made. And additional, when you add the environment variables, the difference is only the environment variables which you want to add in the command, but others are the same.

The test on my side here:

enter image description here

enter image description here

By the way, actually, the update is just a redeploy for the azure container. The difference is that the redeploy is its container image layers are pulled from those cached by the previous deployment.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Thanks for the reply, Charles. The command I posted in the question I changed the names to obscure exactly what I'm working on, which is why the error message references receipt-validator instead of what's in my command. That was my mistake. – Tom Irving Aug 12 '19 at 15:08
  • In the end, I've just gone with a container group configured via a yaml file. – Tom Irving Aug 12 '19 at 15:08
  • @TomIrving If the name is right. Then the command is not wrong and it works well. You need to make sure it's the same with the create command except the environment variables. – Charles Xu Aug 13 '19 at 00:47