Azure / Azure/azure-cli

Support dashes in environment variables when creating containers

Open
#21,047 6 comments 2 reactions 0 assignees View on GitHub
act-observability-squad Container Instances Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Is your feature request related to a problem? Please describe.**
I was creating a container deployment with `az container create ... -e some-var=someValue` and I got an error message that the variable name is invalid. To be precise, this error:
```
ERROR: (InvalidContainerEnvironmentVariable) The environment variable name in container 'mycontainer' of container group 'mycontainer' is invalid. A valid environment variable name must start with alphabetic character or '_', followed by a string of alphanumeric characters or '_' (e.g. 'my_name', or 'MY_NAME', or 'MyName').
Code: InvalidContainerEnvironmentVariable
```

**Describe the solution you'd like**
Env vars are usually used to pass configuration settings to the container. If the software is using some third party package that expects config settings with a dash in the name, there's nothing we can do to change it. The dash in env vars is supported in docker-compose (for example) and property names with dashes are supported in appsettings.config in .net core apps. So, supporting env vars with dashes in the name will be good (in a Linux environment, using the shell `export` command it's not possible to have an dash in the name, but it is possible to have it when using the `env` command, so the shells can support it)

**Describe alternatives you've considered**
The alternative will be outside of `az` CLI scope. Perhaps in .net core settings to interpret a triple underscore as a dash or some other way to escape it for env vars. For our own programs, we can change the settings not to use a dash, but for third party tools, there's nothing we can do.

**Additional context**
Not sure what mechanism `az` will use to set the env vars in the Azure deployment, but the command `env` in Linux works for setting env vars with dashes in the name. I have tested with docker-compose setting env vars with dashes and then reading them from a .net core app in a container and they do work

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.