You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your services might require certain passwords, connection strings, and other secrets, such as for databases or other secure Azure services. By setting the values of these secrets in configuration files, you can make them available in your code as environment variables. These must be handled with care to avoid compromising the security of the secrets.
12
12
13
-
Azure Dev Spaces provides two recommended, streamlined options for storing secrets in Helm charts generated by the Azure Dev Spaces client tooling: in the values.dev.yaml file, and inline directly in azds.yaml. It's not recommended to store secrets in values.yaml. Outside of the two approaches for Helm charts generated by the client tooling defined in this article, if you create your own Helm chart, you can use the Helm chart directly to manage and store secrets.
13
+
Azure Dev Spaces provides two recommended, streamlined options for storing secrets in Helm charts generated by the Azure Dev Spaces client tooling: in the `values.dev.yaml` file, and inline directly in `azds.yaml`. It's not recommended to store secrets in `values.yaml`. Outside of the two approaches for Helm charts generated by the client tooling defined in this article, if you create your own Helm chart, you can use the Helm chart directly to manage and store secrets.
14
14
15
15
## Method 1: values.dev.yaml
16
16
1. Open VS Code with your project that is enabled for Azure Dev Spaces.
@@ -56,7 +56,7 @@ Azure Dev Spaces provides two recommended, streamlined options for storing secre
56
56
7. Make sure that you add _values.dev.yaml_ to the _.gitignore_ file to avoid committing secrets in source control.
57
57
58
58
59
-
## Method 2: Inline directly in azds.yaml
59
+
## Method 2: azds.yaml
60
60
1. In _azds.yaml_, set secrets under the yaml section configurations/develop/install. Although you can enter secret values directly there, it's not recommended because _azds.yaml_ is checked into source control. Instead, add placeholders using the "$PLACEHOLDER" syntax.
61
61
62
62
```yaml
@@ -99,6 +99,44 @@ Azure Dev Spaces provides two recommended, streamlined options for storing secre
99
99
kubectl get secret --namespace default -o yaml
100
100
```
101
101
102
+
## Passing secrets as build arguments
103
+
104
+
The previous sections showed how to pass secrets to use at container run time. You can also pass a secret at container build time, such as a password for a private NuGet, using `azds.yaml`.
105
+
106
+
In `azds.yaml`, set the build time secrets in *configurations.develop.build.args* using the `<variable name>: ${secret.<secret name>.<secret key>}` syntax. For example:
In the above example, *mynugetsecret* is an existing secret and *pattoken* is an existing key.
120
+
121
+
>[!NOTE]
122
+
> Secret names and keys may contain the `.` character. Use `\` to escape `.` when passing secrets as build arguments. For example, to pass a secret named *foo.bar* with the key of *token*: `MYTOKEN: ${secret.foo\.bar.token}`. In addition, secrets can be evaluated with prefix and postfix text. For example, `MYURL: eus-${secret.foo\.bar.token}-version1`. Also, secrets available in parent and grandparent spaces can be passed as build arguments.
123
+
124
+
In your Dockerfile, use the *ARG* directive to consume the secret, then use that same variable later in the Dockerfile. For example:
0 commit comments