Skip to content

Commit 44ffd02

Browse files
authored
[Storage] Support blob tag (Azure#15742)
* [Storage] Support blob tag (Azure#12475) * revise change log per review comments
1 parent f8e8e6b commit 44ffd02

File tree

58 files changed

+1968
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1968
-131
lines changed

src/Storage/Storage.Management/Az.Storage.psd1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ CmdletsToExport = 'Get-AzStorageAccount', 'Get-AzStorageAccountKey',
188188
'Disable-AzStorageContainerDeleteRetentionPolicy',
189189
'Restore-AzStorageContainer',
190190
'Enable-AzStorageBlobLastAccessTimeTracking',
191-
'Disable-AzStorageBlobLastAccessTimeTracking'
191+
'Disable-AzStorageBlobLastAccessTimeTracking',
192+
'Set-AzStorageBlobTag', 'Get-AzStorageBlobTag',
193+
'Get-AzStorageBlobByTag'
192194

193195
# Variables to export from this module
194196
# VariablesToExport = @()

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Supported get/set blob tags on a specific blob
22+
- `Get-AzStorageBlobTag`
23+
- `Set-AzStorageBlobTag`
24+
* Supported create destination blob with specific blob tags while upload/copy Blob
25+
- `Set-AzStorageBlobContent`
26+
- `Start-AzStorageBlobCopy`
27+
* Supported list blobs across containers with a blob tag filter sql expression
28+
- `Get-AzStorageBlobByTag`
29+
* Supported list blobs inside a container and include Blob Tags
30+
- `Get-AzStorageBlob`
31+
* Supported run blob operation with blob tag condition, and fail the cmdlet when blob tag condition not match
32+
- `Get-AzStorageBlob`
33+
- `Get-AzStorageBlobContent`
34+
- `Get-AzStorageBlobTag`
35+
- `Remove-AzStorageBlob`
36+
- `Set-AzStorageBlobContent`
37+
- `Set-AzStorageBlobTag`
38+
- `Start-AzStorageBlobCopy`
39+
- `Stop-AzStorageBlobCopy`
2140
* Generate blob sas token with new API version
2241
- `New-AzStorageBlobSASToken`
2342
- `New-AzStorageContainerSASToken`

src/Storage/Storage.Management/help/Az.Storage.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ Get the NetWorkRule property of a Storage account
9898
### [Get-AzStorageBlob](Get-AzStorageBlob.md)
9999
Lists blobs in a container.
100100

101+
### [Get-AzStorageBlobByTag](Get-AzStorageBlobByTag.md)
102+
Lists blobs in a storage account across containers, with a blob tag filter sql expression.
103+
101104
### [Get-AzStorageBlobContent](Get-AzStorageBlobContent.md)
102105
Downloads a storage blob.
103106

@@ -113,6 +116,9 @@ Applies a simple Structured Query Language (SQL) statement on a blob's contents
113116
### [Get-AzStorageBlobServiceProperty](Get-AzStorageBlobServiceProperty.md)
114117
Gets service properties for Azure Storage Blob services.
115118

119+
### [Get-AzStorageBlobTag](Get-AzStorageBlobTag.md)
120+
Get blob tags of a specific blob.
121+
116122
### [Get-AzStorageContainer](Get-AzStorageContainer.md)
117123
Lists the storage containers.
118124

@@ -374,6 +380,9 @@ Uploads a local file to an Azure Storage blob.
374380
### [Set-AzStorageBlobInventoryPolicy](Set-AzStorageBlobInventoryPolicy.md)
375381
Creates or updates blob inventory policy in a Storage account.
376382

383+
### [Set-AzStorageBlobTag](Set-AzStorageBlobTag.md)
384+
Set blob tags of a specific blob.
385+
377386
### [Set-AzStorageContainerAcl](Set-AzStorageContainerAcl.md)
378387
Sets the public access permission to a storage container.
379388

src/Storage/Storage.Management/help/Copy-AzStorageBlob.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ Copy a blob synchronously.
1616
```
1717
Copy-AzStorageBlob [-SrcBlob] <String> -SrcContainer <String> -DestContainer <String> [-DestBlob <String>]
1818
[-StandardBlobTier <String>] [-RehydratePriority <RehydratePriority>] [-EncryptionScope <String>]
19-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-AsJob]
19+
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-AsJob] [-TagCondition <String>]
2020
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
### BlobInstance
2424
```
2525
Copy-AzStorageBlob [-BlobBaseClient <BlobBaseClient>] -DestContainer <String> [-DestBlob <String>]
2626
[-StandardBlobTier <String>] [-RehydratePriority <RehydratePriority>] [-EncryptionScope <String>]
27-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-AsJob]
27+
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-AsJob] [-TagCondition <String>]
2828
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2929
```
3030

3131
### UriPipeline
3232
```
3333
Copy-AzStorageBlob -AbsoluteUri <String> -DestContainer <String> -DestBlob <String>
3434
[-StandardBlobTier <String>] [-RehydratePriority <RehydratePriority>] [-EncryptionScope <String>]
35-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-AsJob]
35+
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-AsJob] [-TagCondition <String>]
3636
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3737
```
3838

@@ -312,6 +312,21 @@ Accept pipeline input: False
312312
Accept wildcard characters: False
313313
```
314314
315+
### -TagCondition
316+
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://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations#tags-conditional-operations.
317+
318+
```yaml
319+
Type: System.String
320+
Parameter Sets: (All)
321+
Aliases:
322+
323+
Required: False
324+
Position: Named
325+
Default value: None
326+
Accept pipeline input: False
327+
Accept wildcard characters: False
328+
```
329+
315330
### -Confirm
316331
Prompts you for confirmation before running the cmdlet.
317332
@@ -344,7 +359,7 @@ Accept wildcard characters: False
344359
```
345360
346361
### CommonParameters
347-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
362+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
348363
349364
## INPUTS
350365

src/Storage/Storage.Management/help/Get-AzStorageBlob.md

Lines changed: 85 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,32 @@ Lists blobs in a container.
1515

1616
### BlobName (Default)
1717
```
18-
Get-AzStorageBlob [[-Blob] <String>] [-Container] <String> [-IncludeDeleted] [-MaxCount <Int32>]
19-
[-ContinuationToken <BlobContinuationToken>] [-Context <IStorageContext>] [-ServerTimeoutPerRequest <Int32>]
20-
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
21-
[<CommonParameters>]
18+
Get-AzStorageBlob [[-Blob] <String>] [-Container] <String> [-IncludeDeleted] [-IncludeTag] [-MaxCount <Int32>]
19+
[-ContinuationToken <BlobContinuationToken>] [-TagCondition <String>] [-Context <IStorageContext>]
20+
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
21+
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
2222
```
2323

2424
### SingleBlobSnapshotTime
2525
```
26-
Get-AzStorageBlob [-Blob] <String> [-Container] <String> [-IncludeDeleted] -SnapshotTime <DateTimeOffset>
27-
[-MaxCount <Int32>] [-ContinuationToken <BlobContinuationToken>] [-Context <IStorageContext>]
28-
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
29-
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
26+
Get-AzStorageBlob [-Blob] <String> [-Container] <String> [-IncludeDeleted] [-IncludeTag]
27+
-SnapshotTime <DateTimeOffset> [-MaxCount <Int32>] [-ContinuationToken <BlobContinuationToken>]
28+
[-TagCondition <String>] [-Context <IStorageContext>] [-ServerTimeoutPerRequest <Int32>]
29+
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
30+
[<CommonParameters>]
3031
```
3132

3233
### SingleBlobVersionID
3334
```
34-
Get-AzStorageBlob [-Blob] <String> [-Container] <String> [-IncludeDeleted] -VersionId <String>
35-
[-MaxCount <Int32>] [-ContinuationToken <BlobContinuationToken>] [-Context <IStorageContext>]
36-
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
35+
Get-AzStorageBlob [-Blob] <String> [-Container] <String> [-IncludeDeleted] [-IncludeTag] -VersionId <String>
36+
[-MaxCount <Int32>] [-ContinuationToken <BlobContinuationToken>] [-TagCondition <String>]
37+
[-Context <IStorageContext>] [-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
3738
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
3839
```
3940

4041
### BlobPrefix
4142
```
42-
Get-AzStorageBlob [-Prefix <String>] [-Container] <String> [-IncludeDeleted] [-IncludeVersion]
43+
Get-AzStorageBlob [-Prefix <String>] [-Container] <String> [-IncludeDeleted] [-IncludeVersion] [-IncludeTag]
4344
[-MaxCount <Int32>] [-ContinuationToken <BlobContinuationToken>] [-Context <IStorageContext>]
4445
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
4546
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
@@ -147,6 +148,43 @@ blob1 BlockBlob 2097152 application/octet-stream 20
147148

148149
This command gets a single blobs snapshot with SnapshotTime.
149150

151+
### Example 8: Get blob include blob tags
152+
```
153+
PS C:\> $blobs = Get-AzStorageBlob -Container "containername" -IncludeTag
154+
155+
PS C:\> $blobs
156+
157+
AccountName: storageaccountname, ContainerName: containername
158+
159+
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted VersionId
160+
---- -------- ------ ----------- ------------ ---------- ------------ --------- ---------
161+
testblob BlockBlob 2097152 application/octet-stream 2020-07-23 09:35:02Z Hot False 2020-07-23T09:35:02.8527357Z *
162+
testblob2 BlockBlob 2097152 application/octet-stream 2020-07-23 09:35:04Z Hot False 2020-07-23T09:35:04.0856187Z *
163+
164+
165+
PS C:\> $blobs[0].Tags
166+
Name Value
167+
---- -----
168+
tag1 value1
169+
tag2 value2
170+
```
171+
172+
This command lists blobs from a container with blob tags, and show the tags of the first blob.
173+
174+
### Example 9: Get a single blob with blob tag condition
175+
```
176+
PS C:\> Get-AzStorageBlob -Container "containername" -Blob testblob -TagCondition """tag1""='value1'"
177+
178+
AccountName: storageaccountname, ContainerName: containername
179+
180+
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted VersionId
181+
---- -------- ------ ----------- ------------ ---------- ------------ --------- ---------
182+
testblob BlockBlob 2097152 application/octet-stream 2020-07-23 09:35:02Z Hot False 2020-07-23T09:35:02.8527357Z *
183+
```
184+
185+
This command gets a single blob with blob tag condition.
186+
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.
187+
150188
## PARAMETERS
151189

152190
### -Blob
@@ -163,7 +201,7 @@ Required: False
163201
Position: 0
164202
Default value: None
165203
Accept pipeline input: False
166-
Accept wildcard characters: False
204+
Accept wildcard characters: True
167205
```
168206
169207
```yaml
@@ -175,7 +213,7 @@ Required: True
175213
Position: 0
176214
Default value: None
177215
Accept pipeline input: False
178-
Accept wildcard characters: False
216+
Accept wildcard characters: True
179217
```
180218
181219
### -ClientTimeoutPerRequest
@@ -291,6 +329,21 @@ Accept pipeline input: False
291329
Accept wildcard characters: False
292330
```
293331
332+
### -IncludeTag
333+
Include blob tags, by default get blob won't include blob tags.
334+
335+
```yaml
336+
Type: System.Management.Automation.SwitchParameter
337+
Parameter Sets: (All)
338+
Aliases:
339+
340+
Required: False
341+
Position: Named
342+
Default value: None
343+
Accept pipeline input: False
344+
Accept wildcard characters: False
345+
```
346+
294347
### -IncludeVersion
295348
Blob versions will be listed only if this parameter is present, by default get blob won't include blob versions.
296349
@@ -370,6 +423,23 @@ Accept pipeline input: False
370423
Accept wildcard characters: False
371424
```
372425
426+
### -TagCondition
427+
Optional Tag expression statement to check match condition.
428+
The blob request will fail when the blob tags does not match the given expression.
429+
See details in https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations#tags-conditional-operations.
430+
431+
```yaml
432+
Type: System.String
433+
Parameter Sets: BlobName, SingleBlobSnapshotTime, SingleBlobVersionID
434+
Aliases:
435+
436+
Required: False
437+
Position: Named
438+
Default value: None
439+
Accept pipeline input: False
440+
Accept wildcard characters: False
441+
```
442+
373443
### -VersionId
374444
Blob VersionId
375445
@@ -386,7 +456,7 @@ Accept wildcard characters: False
386456
```
387457
388458
### CommonParameters
389-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
459+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
390460
391461
## INPUTS
392462

0 commit comments

Comments
 (0)