MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.01k stars 21k forks source link

Is it possible to add/remove/edit the Environment variables after the container instance has been created? #31168

Closed blueelvis closed 4 years ago

blueelvis commented 5 years ago

As per the documentation above, you cannot change the environment variables after the container instance has been deployed. Am I missing something or is it just not possible and the only option right now is to recreate the container instance?

Thanks, Pranav


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

VikasPullagura-MSFT commented 5 years ago

@blueelvis Thanks for the question! We are investigating and will update you shortly.

VikasPullagura-MSFT commented 5 years ago

@blueelvis While creating the Container instance you can specify the Environmental variables, memory, size etc. If you have created through Azure Portal, you can export container group in yaml format. You can modify the yaml and change the Environmental variables and then use az container create command that will internally redeploy the container. This is the only way to modify any parameter after the container group is created.

VikasPullagura-MSFT commented 5 years ago

@blueelvis Is there any update.

blueelvis commented 5 years ago

@VikasPullagura-MSFT -- Oh ok. Looks like it is not supported from the portal. I think we should add the steps to change the environment variables using this. Do you mind if I take a stab at this?

Also, it seems that this is only possible through the AZ Cli and not even using the PowerShell commandlets? I don't see a commandlet to output the YAML file.

VikasPullagura-MSFT commented 5 years ago

@blueelvis Thanks for the feedback. I will let the content author comment on this.

VikasPullagura-MSFT commented 5 years ago

@dlepow can you please add your comments for the customer query.

dlepow commented 4 years ago

Hello @blueelvis - Thanks for the questions. Our documentation here states that you can update a running container group by modifying a group property or a container property such as environment variables. You should be able to do this through a YAML file as @VikasPullagura-MSFT explained, or by using a Resource Manager template, or by running the az container create CLI command or New-AzContainerGroup cmdlet and specify the existing resource group and container group names with at least one changed property. Please let us know if this helps answer your question. Out of curiosity, what type of workload is the container running - is it a long-running service, or a run-once task?

blueelvis commented 4 years ago

@dlepow - Thanks for the answers! Yea, I was pretty confused as to how to change the container environment variables. az container create and New-AzContainerGroup suggest that they would be creating new containers as per the Verb-Noun as from what I have seen (Like the WebApp), there would az webapp update and Set-AzWebApp which suggest that they will modify the current setup. Just curious but why in this case it is like this?

The workload currently is a private VSTS agent which is continuously running but I trying to move it so that it is a run-once task for which I need to experiment with various settings and doing this i.e. to download the yaml and then update again feels cumbersome :)

-Pranav

mimckitt commented 4 years ago

@blueelvis its a good question as to why the commands are not az container update such as with a Web App. I personally don't know the exact reason behind it. But at the very least, I am glad to hear this issue was made clear and you can continue with your work :)

For reference, you can see all the commands and what they do for containers here

https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest

We will close this as no doc updates are needed. If you need anything else just let us know.

scyto commented 4 years ago

@MicahMcKittrick-MSFT this is the most confusing document i have ever read, it took 3 reads to realize the Num Words and Min Length were variables - I thought i had to run the wordcount container. Can i suggest breaking this doc down into scenarios for the unitiated.

  1. set variables on create (and use examples lie VarName and VarValue - not the name of greeks
  2. modify variables on created container etc

I still don't understand how to do the latter, to be clear, i am pretty familliar with docker, docker hub. moreover just give a UI to set them after the container is created - heck even a synology NAS has that!

Regenhardt commented 2 years ago

Or maybe a REST endpoint to recreate the container with new settings, mirroring the az cli?

mcraiha commented 1 year ago

Sorry to resurrect this old discussion, but the problem hasn't been addressed. There are issues with the export + create workflow:

  1. Export might return a yaml file with wrong API version
  2. Create method won't work if e.g. Azure Container Registry is used because it requires a password

In current situation it is better to use e.g. Azure App Configuration if you can create the app that is run inside the container by yourself. At least that way the configurations can be edited directly from the browser.

MadhurG-Hexaware commented 1 week ago

Hi, This is really a pain point when we cannot edit the environment variables in portal or with CLI. Also i second the above issue, Create method won't work if e.g. Azure Container Registry is used because it requires a password also even when entering the correct credentials, there is an error message. (InvalidContainerGroupUpdate) The updates on container group 'mst-server' are invalid. If you are going to update the RestartPolicy (old "OnFailure", new "Always") for a container group, you must delete it first and then create a new one. Code: InvalidContainerGroupUpdate Message: The updates on container group 'mst-server' are invalid. If you are going to update the RestartPolicy (old "OnFailure", new "Always") for a container group, you must delete it first and then create a new one.

Ideal way to deal with this is to have Add/Edit feature in portal for quick changes.