Düzenle

Aracılığıyla paylaş


Get-AzStorageBlob

Lists blobs in a container.

Syntax

Get-AzStorageBlob
   [[-Blob] <String>]
   [-Container] <String>
   [-IncludeDeleted]
   [-IncludeTag]
   [-MaxCount <Int32>]
   [-ContinuationToken <BlobContinuationToken>]
   [-TagCondition <String>]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [<CommonParameters>]
Get-AzStorageBlob
   [-Blob] <String>
   [-Container] <String>
   [-IncludeDeleted]
   [-IncludeTag]
   -SnapshotTime <DateTimeOffset>
   [-MaxCount <Int32>]
   [-ContinuationToken <BlobContinuationToken>]
   [-TagCondition <String>]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [<CommonParameters>]
Get-AzStorageBlob
   [-Blob] <String>
   [-Container] <String>
   [-IncludeDeleted]
   [-IncludeTag]
   -VersionId <String>
   [-MaxCount <Int32>]
   [-ContinuationToken <BlobContinuationToken>]
   [-TagCondition <String>]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [<CommonParameters>]
Get-AzStorageBlob
   [-Prefix <String>]
   [-Container] <String>
   [-IncludeDeleted]
   [-IncludeVersion]
   [-IncludeTag]
   [-MaxCount <Int32>]
   [-ContinuationToken <BlobContinuationToken>]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [<CommonParameters>]

Description

The Get-AzStorageBlob cmdlet lists blobs in the specified container in an Azure storage account.

Examples

Example 1: Get a blob by blob name

Get-AzStorageBlob -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

Get-AzStorageContainer -Name container* | Get-AzStorageBlob -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

Get-AzStorageBlob -Container "ContainerName" -Prefix "blob"

This command uses a name prefix to get blobs.

Example 4: List blobs in multiple batches

$MaxReturn = 10000
$ContainerName = "abc"
$Total = 0
$Token = $Null
do
 {
     $Blobs = Get-AzStorageBlob -Container $ContainerName -MaxCount $MaxReturn  -ContinuationToken $Token
     $Total += $Blobs.Count
     if($Blobs.Length -le 0) { Break;}
     $Token = $Blobs[$blobs.Count -1].ContinuationToken;
 }
 While ($null -ne $Token)
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-AzStorageBlob 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.

Example 5: Get all blobs in a container include blob version

Get-AzStorageBlob -Container "containername"  -IncludeVersion

AccountName: storageaccountname, ContainerName: containername

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId                     
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------                     
blob1                BlockBlob 2097152         application/octet-stream       2020-07-06 06:56:06Z Hot                                     False      2020-07-06T06:56:06.2432658Z  
blob1                BlockBlob 2097152         application/octet-stream       2020-07-06 06:56:06Z Hot        2020-07-06T06:56:06.8588431Z False                                    
blob1                BlockBlob 2097152         application/octet-stream       2020-07-06 06:56:06Z Hot                                     False      2020-07-06T06:56:06.8598431Z *  
blob2                BlockBlob 2097152         application/octet-stream       2020-07-03 16:19:16Z Hot                                     False      2020-07-03T16:19:16.2883167Z  
blob2                BlockBlob 2097152         application/octet-stream       2020-07-03 16:19:35Z Hot                                     False      2020-07-03T16:19:35.2381110Z *

This command gets all blobs in a container include blob version.

Example 6: Get a single blob version

Get-AzStorageBlob -Container "containername" -Blob blob2 -VersionId "2020-07-03T16:19:16.2883167Z"

AccountName: storageaccountname, ContainerName: containername

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId                     
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------                     
blob2                BlockBlob 2097152         application/octet-stream       2020-07-03 16:19:16Z Hot                                     False      2020-07-03T16:19:16.2883167Z

This command gets a single blobs verion with VersionId.

Example 7: Get a single blob snapshot

Get-AzStorageBlob -Container "containername" -Blob blob1 -SnapshotTime "2020-07-06T06:56:06.8588431Z"

AccountName: storageaccountname, ContainerName: containername

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId                     
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------                     
blob1                BlockBlob 2097152         application/octet-stream       2020-07-06 06:56:06Z Hot        2020-07-06T06:56:06.8588431Z False

This command gets a single blobs snapshot with SnapshotTime.

Example 8: Get blob include blob tags

$blobs = Get-AzStorageBlob -Container "containername" -IncludeTag

$blobs

   AccountName: storageaccountname, ContainerName: containername

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId                     
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------                     
testblob             BlockBlob 2097152         application/octet-stream       2020-07-23 09:35:02Z Hot                                     False      2020-07-23T09:35:02.8527357Z *
testblob2            BlockBlob 2097152         application/octet-stream       2020-07-23 09:35:04Z Hot                                     False      2020-07-23T09:35:04.0856187Z *


$blobs[0].Tags
Name          Value 
----          -----
tag1          value1
tag2          value2

This command lists blobs from a container with blob tags, and show the tags of the first blob.

Example 9: Get a single blob with blob tag condition

Get-AzStorageBlob -Container "containername" -Blob testblob -TagCondition """tag1""='value1'"

AccountName: storageaccountname, ContainerName: containername

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId                     
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------                     
testblob             BlockBlob 2097152         application/octet-stream       2020-07-23 09:35:02Z Hot                                     False      2020-07-23T09:35:02.8527357Z *

This command gets a single blob with blob tag condition. The cmdlet will only success when the blob contains a tag with name "tag1" and value "value1", else the cmdlet will fail with error code 412.

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. This parameter supports wildcards anywhere in the string.

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

-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]
Aliases:ClientTimeoutPerRequestInSeconds
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-AzStorageContext 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

-IncludeTag

Include blob tags, by default get blob won't include blob tags.

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

-IncludeVersion

Blob versions will be listed only if this parameter is present, by default get blob won't include blob versions.

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]
Aliases:ServerTimeoutPerRequestInSeconds
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SnapshotTime

Blob SnapshotTime

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

-TagCondition

Optional Tag expression statement to check match condition. The blob request will fail when the blob tags does not match the given expression. See details in https://learn.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations#tags-conditional-operations.

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

-VersionId

Blob VersionId

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

Inputs

String

IStorageContext

Outputs

AzureStorageBlob