Get-AzureStorageBlob

Lists blobs in a container.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

Get-AzureStorageBlob
   [[-Blob] <String>]
   [-Container] <String>
   [-IncludeDeleted]
   [-MaxCount <Int32>]
   [-ContinuationToken <BlobContinuationToken>]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [<CommonParameters>]
Get-AzureStorageBlob
   [-Prefix <String>]
   [-Container] <String>
   [-IncludeDeleted]
   [-MaxCount <Int32>]
   [-ContinuationToken <BlobContinuationToken>]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [<CommonParameters>]

Description

The Get-AzureStorageBlob cmdlet lists blob in the specified container in an Azure storage account.

Examples

Example 1: Get a blob by blob name

PS C:\>Get-AzureStorageBlob -Container "ContainerName" -Blob blob*

This command uses a blob name and wildcard to get a blob.

Example 2: Get blobs in a container by using the pipeline

PS C:\>Get-AzureStorageContainer -Name container* | Get-AzureStorageBlob -IncludeDeleted

   Container Uri: https://storageaccountname.blob.core.windows.net/container1

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime         IsDeleted 
----                 --------  ------          -----------                    ------------         ---------- ------------         --------- 
test1                BlockBlob 403116          application/octet-stream       2017-11-08 07:53:19Z            2017-11-08 08:19:32Z True      
test1                BlockBlob 403116          application/octet-stream       2017-11-08 09:00:29Z                                 True      
test2                BlockBlob 403116          application/octet-stream       2017-11-08 07:53:00Z                                 False

This command uses the pipeline to get all blobs (include blobs in Deleted status) in a container.

Example 3: Get blobs by name prefix

PS C:\>Get-AzureStorageBlob -Container "ContainerName" -Prefix "blob"

This command uses a name prefix to get blobs.

Example 4: List blobs in multiple batches

PS C:\>$MaxReturn = 10000
PS C:\> $ContainerName = "abc"
PS C:\> $Total = 0
PS C:\> $Token = $Null
PS C:\> do
 {
     $Blobs = Get-AzureStorageBlob -Container $ContainerName -MaxCount $MaxReturn  -ContinuationToken $Token
     $Total += $Blobs.Count
     if($Blobs.Length -le 0) { Break;}
     $Token = $Blobs[$blobs.Count -1].ContinuationToken;
 }
 While ($Token -ne $Null)
PS C:\> Echo "Total $Total blobs in container $ContainerName"

This example uses the MaxCount and ContinuationToken parameters to list Azure Storage blobs in multiple batches. The first four commands assign values to variables to use in the example. The fifth command specifies a Do-While statement that uses the Get-AzureStorageBlob cmdlet to get blobs. The statement includes the continuation token stored in the $Token variable. $Token changes value as the loop runs. For more information, type Get-Help About_Do. The final command uses the Echo command to display the total.

Parameters

-Blob

Specifies a name or name pattern, which can be used for a wildcard search. If no blob name is specified, the cmdlet lists all the blobs in the specified container. If a value is specified for this parameter, the cmdlet lists all blobs with names that match this parameter.

Type:String
Position:0
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ClientTimeoutPerRequest

Specifies the client-side time-out interval, in seconds, for one service request. If the previous call fails in the specified interval, this cmdlet retries the request. If this cmdlet does not receive a successful response before the interval elapses, this cmdlet returns an error.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ConcurrentTaskCount

Specifies the maximum concurrent network calls. You can use this parameter to limit the concurrency to throttle local CPU and bandwidth usage by specifying the maximum number of concurrent network calls. The specified value is an absolute count and is not multiplied by the core count. This parameter can help reduce network connection problems in low bandwidth environments, such as 100 kilobits per second. The default value is 10.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Container

Specifies the name of the container.

Type:String
Aliases:N, Name
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Context

Specifies the Azure storage account from which you want to get a list of blobs. You can use the New-AzureStorageContext cmdlet to create a storage context.

Type:IStorageContext
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ContinuationToken

Specifies a continuation token for the blob list. Use this parameter and the MaxCount parameter to list blobs in multiple batches.

Type:BlobContinuationToken
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IncludeDeleted

Include Deleted Blob, by default get blob won't include deleted blob.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaxCount

Specifies the maximum number of objects that this cmdlet returns.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Prefix

Specifies a prefix for the blob names that you want to get. This parameter does not support using regular expressions or wildcard characters to search. This means that if the container has only blobs named "My", "MyBlob1", and "MyBlob2" and you specify "-Prefix My*", the cmdlet returns no blobs. However, if you specify "-Prefix My", the cmdlet returns "My", "MyBlob1", and "MyBlob2".

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ServerTimeoutPerRequest

Specifies the service side time-out interval, in seconds, for a request. If the specified interval elapses before the service processes the request, the storage service returns an error.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

IStorageContext

Outputs

AzureStorageBlob