<p>I'm trying to setup the <a href="https://learn.microsoft.com/en-us/azure/cognitive-services/Face/face-resource-container-config" rel="nofollow noreferrer">Azure Face recognition container</a>, but wondering how to use a k8 secret as a Docker command "argument."</p>

<p>This works, but I need to replace the ApiKey with my k8 secret.</p>

<pre><code>{
  "kind": "Deployment",
  "spec": {
    "template": {
      "spec": {
        "containers": [
          {
            "name": "azure-face",
            "args": [
              "Eula=accept",
              "Billing=https://microsoft.com",
              "ApiKey=123"
            ]
          }
        ]
      }
    }
  }
}
</code></pre>

<p>Create secret like this:</p>

<pre><code>kubectl create secret generic azure-api-key --from-literal=azure-api-key="123"
</code></pre>

<p>Tried changing the container args like this but it doesn't work - arugment is not passed as expected:
(also tried other variations like ApiKey=${AZURE_API_KEY})</p>

<pre><code>    "containers": [
      {
        "args": [
          "Eula=accept",
          "Billing=https://microsoft.com",
          "ApiKey=$AZURE_API_KEY"
        ],
        "env": [
          {
            "name": "AZURE_API_KEY",
            "valueFrom": {
              "secretKeyRef": {
                "name": "azure-api-key",
                "key": "azure-api-key"
              }
            }
          }
        ]
      }
    ]
</code></pre>

<p>Also did docker exec and from inside container verified that:</p>

<pre><code>$ echo $AZURE_API_KEY
$ 123
</code></pre>

Charlie
<p>Looks like this was the issue thanks to @Blokje5:</p>

<blockquote>
  <p>Note: The environment variable appears in parentheses, "$(VAR)". This
  is required for the variable to be expanded in the command or args
  field.</p>
</blockquote>

<p>I had tried ${VAR} not $(VAR).</p>
