Get-AzContainerInstanceLog
Synopsis: Retrieves the logs of a container instance in Azure Container Instances.
Syntax
Get-AzContainerInstanceLog
-ResourceGroupName <String>
-Name <String>
[-ContainerName <String>]
[-Tail <Int32>]
[-Since <DateTime>]
[-Follow]
[<CommonParameters>]
Parameters
| Parameter | Type | Description |
|---|---|---|
| -ResourceGroupName | String | Name of the resource group containing the container instance. |
| -Name | String | Name of the container instance. |
| -ContainerName | String | Specific container within the instance. Optional; if omitted, logs from all containers are returned. |
| -Tail | Int32 | Number of lines from the end of the logs to retrieve. Default is all lines. |
| -Since | DateTime | Return logs since this timestamp. Accepts ISO 8601 format. |
| -Follow | SwitchParameter | Continuously stream new log entries until the command is stopped. |
| -WhatIf | SwitchParameter | Shows what would happen if the command runs. |
| -Confirm | SwitchParameter | Prompts for confirmation before executing. |
Examples
Example 1: Retrieve the last 100 lines of logs for a container instance.
Get-AzContainerInstanceLog -ResourceGroupName "MyRG" -Name "myContainerInstance" -Tail 100
Example 2: Stream logs in real‑time for a specific container.
Get-AzContainerInstanceLog -ResourceGroupName "MyRG" -Name "myContainerInstance" -ContainerName "web" -Follow