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
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-tasks-authentication-key-vault.md
+48-75Lines changed: 48 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,26 +63,33 @@ In a real-world scenario, secrets would likely be set and maintained in a separa
63
63
64
64
## Define task steps in YAML file
65
65
66
-
The steps for this example task are defined in a [YAML file](container-registry-tasks-reference-yaml.md). Create a file named `dockerhubtask.yaml` in a local working directory and paste the following contents. Be sure to replace the `hubuser/hubrepo` alias with the name of your private repo in Docker Hub.
66
+
The steps for this example task are defined in a [YAML file](container-registry-tasks-reference-yaml.md). Create a file named `dockerhubtask.yaml` in a local working directory and paste the following contents. Be sure to replace the key vault name in the file with the name of your key vault.
67
67
68
68
```yml
69
69
version: v1.1.0
70
-
# Replace hubuser/hubrepo with name of private repo in Docker Hub
71
-
alias:
72
-
values:
73
-
REPO: hubuser/hubrepo
70
+
# Replace mykeyvault with the name of your key vault
* Manage secret credentials to authenticate with Docker Hub.
89
+
* Authenticate with Docker Hub by passing the secrets to the `docker login` command.
83
90
* Build an image using a sample Dockerfile in the [Azure-Samples/acr-tasks](https://github.com/Azure-Samples/acr-tasks.git) repo.
84
-
* Tag the image for a private Docker Hub repository
85
-
* Push the image to the Docker Hub repository.
91
+
* Push the image to the private Docker Hub repository.
92
+
86
93
87
94
## Option 1: Create task with user-assigned identity
88
95
@@ -135,93 +142,59 @@ az keyvault set-policy --name mykeyvault \
135
142
--secret-permissions get
136
143
```
137
144
138
-
## Add Docker Hub credentials to the task
139
-
140
-
Now use the [az acr task credential add][az-acr-task-credential-add] command to enable the task to authenticate with Docker Hub using the credentials accessed from the key vault. The managed identity has access to the credentials in the vault.
141
-
142
-
Run the command corresponding to the type of managed identity you enabled in the task. If you enabled a user-assigned identity, pass `--use-identity` with the client ID of the identity. If you enabled a system-assigned identity, pass `--use-identity [system]`.
143
-
144
-
```azurecli
145
-
# Add credentials to task accessed with user-assigned identity
To verify that the task in which you enabled a managed identity runs successfully, manually trigger the task with the [az acr task run][az-acr-task-run] command.
167
148
168
149
```azurecli
169
-
az acr task run --name dockerhubtask --registry myregistry
150
+
az acr task run --name dockerhubtask --registry myregistry --set PrivateRepo=hubuser/hubrepo
170
151
```
171
152
172
153
When the task runs successfully, output shows successful authentication to Docker Hub, and the image is successfully built and pushed to the private repo:
173
154
174
155
```console
175
-
Queued a run with ID: cfr
156
+
Queued a run with ID: cf24
176
157
Waiting for an agent...
177
-
2020/01/15 22:01:45 Alias support enabled for version >= 1.1.0, please see https://aka.ms/acr/tasks/task-aliases for more information.
0 commit comments