Skip to content

Commit ccd3d3a

Browse files
authored
Merge pull request #107056 from dlepow/tasklogs
[ACR] Tasks logs
2 parents 330517c + 0156084 commit ccd3d3a

File tree

6 files changed

+125
-9
lines changed

6 files changed

+125
-9
lines changed

articles/container-registry/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@
181181
href: container-registry-tasks-authentication-key-vault.md
182182
- name: Build image with Buildpacks (preview)
183183
href: container-registry-tasks-pack-build.md
184+
- name: View task logs
185+
href: container-registry-tasks-logs.md
184186
- name: Reference
185187
expanded: false
186188
items:

articles/container-registry/container-registry-auto-purge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ At a minimum, specify the following when you run `acr purge`:
4242

4343
For additional parameters, run `acr purge --help`.
4444

45-
`acr purge` supports other features of ACR Tasks commands including [run variables](container-registry-tasks-reference-yaml.md#run-variables) and [task run logs](container-registry-tasks-overview.md#view-task-logs) that are streamed and also saved for later retrieval.
45+
`acr purge` supports other features of ACR Tasks commands including [run variables](container-registry-tasks-reference-yaml.md#run-variables) and [task run logs](container-registry-tasks-logs.md) that are streamed and also saved for later retrieval.
4646

4747
### Run in an on-demand task
4848

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: View task run logs - Tasks
3+
description: How to view and manage run logs generated by ACR Tasks.
4+
ms.topic: article
5+
ms.date: 03/09/2020
6+
---
7+
8+
# View and manage task run logs
9+
10+
Each task run in [Azure Container Registry tasks](container-registry-tasks-overview.md) generates log output that you can inspect to determine whether the task steps ran successfully.
11+
12+
This article explains how to view and manage task run logs.
13+
14+
## View streamed logs
15+
16+
When you trigger a task manually, log output is streamed directly to the console. For example, when you trigger a task manually by using the [az acr build](/cli/azure/acr#az-acr-build), [az acr run](/cli/azure/acr#az-acr-run), or [az acr task run](/cli/azure/acr/task#az-acr-task-run) command, you see log output streamed to the console.
17+
18+
The following sample [az acr run](/cli/azure/acr#az-acr-run) command manually triggers a task that runs a container pulled from the same registry:
19+
20+
```azurecli
21+
az acr run --registry mycontainerregistry1220 \
22+
--cmd '$Registry/samples/hello-world:v1' /dev/null
23+
```
24+
25+
Streamed log:
26+
27+
```console
28+
Queued a run with ID: cf4
29+
Waiting for an agent...
30+
2020/03/09 20:30:10 Alias support enabled for version >= 1.1.0, please see https://aka.ms/acr/tasks/task-aliases for more information.
31+
2020/03/09 20:30:10 Creating Docker network: acb_default_network, driver: 'bridge'
32+
2020/03/09 20:30:10 Successfully set up Docker network: acb_default_network
33+
2020/03/09 20:30:10 Setting up Docker configuration...
34+
2020/03/09 20:30:11 Successfully set up Docker configuration
35+
2020/03/09 20:30:11 Logging in to registry: mycontainerregistry1220azurecr.io
36+
2020/03/09 20:30:12 Successfully logged into mycontainerregistry1220azurecr.io
37+
2020/03/09 20:30:12 Executing step ID: acb_step_0. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
38+
2020/03/09 20:30:12 Launching container with name: acb_step_0
39+
Unable to find image 'mycontainerregistry1220azurecr.io/samples/hello-world:v1' locally
40+
v1: Pulling from samples/hello-world
41+
Digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e888a
42+
Status: Downloaded newer image for mycontainerregistry1220azurecr.io/samples/hello-world:v1
43+
44+
Hello from Docker!
45+
This message shows that your installation appears to be working correctly.
46+
[...]
47+
48+
2020/03/09 20:30:13 Successfully executed container: acb_step_0
49+
2020/03/09 20:30:13 Step ID: acb_step_0 marked as successful (elapsed time in seconds: 1.180081)
50+
51+
Run ID: cf4 was successful after 5s
52+
```
53+
54+
## View stored logs
55+
56+
Azure Container Registry stores run logs for all tasks. You can view stored run logs in the Azure portal. Or, use the [az acr task logs](/cli/azure/acr/task#az-acr-task-logs) command to view a selected log. By default, logs are retained for 30 days.
57+
58+
If a task is automatically triggered, for example by a source code update, accessing the stored logs is the *only* way to view the run logs. Automatic task triggers include source code commits or pull requests, base image updates, and timer triggers.
59+
60+
To view run logs in the portal:
61+
62+
1. Navigate to your container registry.
63+
1. In **Services**, select **Tasks** > **Runs**.
64+
1. Select a **Run Id** to view the run status and run logs. The log contains the same information as a streamed log, if one is generated.
65+
66+
![View task run login portal](./media/container-registry-tasks-logs/portal-task-run-logs.png)
67+
68+
To view a log using the Azure CLI, run [az acr task logs](/cli/azure/acr/task#az-acr-task-logs) and specify a run ID, a task name, or a specific image create by a build task. If a task name is specified, the command shows the log for the last created run.
69+
70+
The following example outputs the log for the run with ID *cf4*:
71+
72+
```azurecli
73+
az acr task logs --registry mycontainerregistry1220 \
74+
--run-id cf4
75+
```
76+
77+
## Alternative log storage
78+
79+
You might want to store task run logs on a local file system or use an alternative archiving solution such as Azure Storage.
80+
81+
For example, create a local *tasklogs* directory, and redirect the output of [az acr task logs](/cli/azure/acr/task#az-acr-task-logs) to a local file:
82+
83+
```azurecli
84+
mkdir ~/tasklogs
85+
86+
az acr task logs --registry mycontainerregistry1220 \
87+
--run-id cf4 > ~/tasklogs/cf4.log
88+
```
89+
90+
You can also save local log files to Azure Storage. For example, use the [Azure CLI](../storage/blobs/storage-quickstart-blobs-cli.md), the [Azure portal](../storage/blobs/storage-quickstart-blobs-portal.md), or other methods to upload files to a storage account.
91+
92+
93+
## Next steps
94+
95+
* Learn more about [Azure Container Registry Tasks](container-registry-tasks-overview.md)
96+
97+
<!-- LINKS - External -->
98+
[base-alpine]: https://hub.docker.com/_/alpine/
99+
[base-dotnet]: https://hub.docker.com/r/microsoft/dotnet/
100+
[base-node]: https://hub.docker.com/_/node/
101+
[base-windows]: https://hub.docker.com/r/microsoft/nanoserver/
102+
[sample-archive]: https://github.com/Azure-Samples/acr-build-helloworld-node/archive/master.zip
103+
[terms-of-use]: https://azure.microsoft.com/support/legal/preview-supplemental-terms/
104+
105+
<!-- LINKS - Internal -->
106+
[azure-cli]: /cli/azure/install-azure-cli
107+
[az-acr-build]: /cli/azure/acr#az-acr-build
108+
[az-acr-pack-build]: /cli/azure/acr/pack#az-acr-pack-build
109+
[az-acr-task]: /cli/azure/acr/task
110+
[az-acr-task-create]: /cli/azure/acr/task#az-acr-task-create
111+
[az-acr-task-run]: /cli/azure/acr/task#az-acr-task-run
112+
[az-acr-task-update]: /cli/azure/acr/task#az-acr-task-update
113+
[az-login]: /cli/azure/reference-index#az-login
114+
[az-login-service-principal]: /cli/azure/authenticate-azure-cli
115+
116+
<!-- IMAGES -->
117+
[quick-build-01-fork]: ./media/container-registry-tutorial-quick-build/quick-build-01-fork.png
118+
[quick-build-02-browser]: ./media/container-registry-tutorial-quick-build/quick-build-02-browser.png

articles/container-registry/container-registry-tasks-overview.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,11 @@ By default, ACR Tasks builds images for the Linux OS and the amd64 architecture.
119119
| Linux | amd64<br/>arm<br/>arm64<br/>386 |
120120
| Windows | amd64 |
121121

122-
## View task logs
122+
## View task output
123123

124-
Each task run generates log output that you can inspect to determine whether the task steps ran successfully. If you use the [az acr build](/cli/azure/acr#az-acr-build), [az acr run](/cli/azure/acr#az-acr-run), or [az acr task run](/cli/azure/acr/task#az-acr-task-run) command to trigger the task, log output for the task run is streamed to the console and also stored for later retrieval. When a task is automatically triggered, for example by a source code commit or a base image update, task logs are only stored. View the logs for a task run in the Azure portal, or use the [az acr task logs](/cli/azure/acr/task#az-acr-task-logs) command.
124+
Each task run generates log output that you can inspect to determine whether the task steps ran successfully. When you trigger a task manually, log output for the task run is streamed to the console and also stored for later retrieval. When a task is automatically triggered, for example by a source code commit or a base image update, task logs are only stored. View the run logs in the Azure portal, or use the [az acr task logs](/cli/azure/acr/task#az-acr-task-logs) command.
125125

126-
By default, data and logs for task runs in a registry are retained for 30 days and then automatically purged. If you want to archive the data for a task run, enable archiving using the [az acr task update-run](/cli/azure/acr/task#az-acr-task-update-run) command. The following example enables archiving for the task run *cf11* in registry *myregistry*.
127-
128-
```azurecli
129-
az acr task update-run --registry myregistry --run-id cf11 --no-archive false
130-
```
126+
See more about [viewing and managing task logs](container-registry-tasks-logs.md).
131127

132128
## Next steps
133129

articles/container-registry/container-registry-tasks-pack-build.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ At a minimum, specify the following when you run `az acr pack build`:
2525
* One of the [supported context locations](container-registry-tasks-overview.md#context-locations) for ACR Tasks, such as a local directory, a GitHub repo, or a remote tarball
2626
* The name of a Buildpack builder image suitable for your application. Azure Container Registry caches builder images such as `cloudfoundry/cnb:0.0.34-cflinuxfs3` for faster builds.
2727

28-
`az acr pack build` supports other features of ACR Tasks commands including [run variables](container-registry-tasks-reference-yaml.md#run-variables) and [task run logs](container-registry-tasks-overview.md#view-task-logs) that are streamed and also saved for later retrieval.
28+
`az acr pack build` supports other features of ACR Tasks commands including [run variables](container-registry-tasks-reference-yaml.md#run-variables) and [task run logs](container-registry-tasks-logs.md) that are streamed and also saved for later retrieval.
2929

3030
## Example: Build Node.js image with Cloud Foundry builder
3131

365 KB
Loading

0 commit comments

Comments
 (0)