0

How can I create an Azure container instance and configure it with an environment variables file? Something that'd be equivalent to Docker's --env-file flag for the run command. I couldn't find a way to do that but I'm new to both Azure and Docker.

So it'd look something like: az container create <...> --env-file myEnvFile where myEnvFile is stored somewhere on Azure so I could grab it, like how Docker can grab such a file locally.

Gal Grünfeld
  • 800
  • 3
  • 9
  • 32

3 Answers3

0

You can find what you want here https://learn.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az-container-create

i.e.

az container create -g MyResourceGroup --name myapp --image myimage:latest --environment-variables key1=value1 key2=value2

Apologies, realised you want it from a file, if running in a script can you not have the file set local environment variables or parse the file to set them and then run the command above?

Simon
  • 1,613
  • 1
  • 12
  • 27
  • Yes, it's possible - just wanted to know if it's possible without it (if Azure has some functionality that enables that - was hoping for just being able to use a flag). – Gal Grünfeld Feb 12 '20 at 14:54
0

I'm really sure there is no parameter to set the environment variables of the Azure container instance from a file only through one command.

You can take a look at the parameter --environment-variables in the command az container create:

A list of environment variables for the container. Space-separated values in 'key=value' format.

It requires the value of a list. So you can read from the file to create a list and then use the list as the value of the parameter --environment-variables in the create command.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
0

As far as I'm aware, from answers and my research, this is currently not supported.

Gal Grünfeld
  • 800
  • 3
  • 9
  • 32