Skip to content

Commit 52dfad0

Browse files
Merge pull request #227353 from tamram/tamram23-0214
add new article for blob versions in .NET (dev guide)
2 parents deb3ac4 + f24480e commit 52dfad0

File tree

7 files changed

+91
-90
lines changed

7 files changed

+91
-90
lines changed

articles/storage/blobs/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ items:
625625
href: storage-blob-container-lease.md
626626
- name: Create and manage snapshots
627627
href: snapshots-manage-dotnet.md
628+
- name: Create and list blob versions
629+
href: versions-manage-dotnet.md
628630
- name: Generate a shared access signature (SAS)
629631
items:
630632
- name: Create a user delegation SAS
67.1 KB
Loading

articles/storage/blobs/snapshots-manage-dotnet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: Create and manage a blob snapshot in .NET
33
titleSuffix: Azure Storage
44
description: Learn how to use the .NET client library to create a read-only snapshot of a blob to back up blob data at a given moment in time.
55
author: pauljewellmsft
6-
ms.author: pauljewell
76

7+
ms.author: pauljewell
88
ms.service: storage
99
ms.topic: how-to
1010
ms.date: 08/27/2020

articles/storage/blobs/storage-blobs-list.md

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ ms.author: pauljewell
88

99
ms.service: storage
1010
ms.topic: how-to
11-
ms.date: 03/28/2022
12-
11+
ms.date: 02/14/2023
1312
ms.subservice: blobs
1413
ms.devlang: csharp
1514
ms.custom: devx-track-csharp, devguide-csharp
@@ -108,40 +107,11 @@ Blob name: FolderA/FolderB/FolderC/blob3.txt
108107
109108
### List blob versions or snapshots
110109

111-
To list blob versions or snapshots, specify the [BlobStates](/dotnet/api/azure.storage.blobs.models.blobstates) parameter with the **Version** or **Snapshot** field. Versions and snapshots are listed from oldest to newest.
110+
To list blob versions or snapshots, specify the [BlobStates](/dotnet/api/azure.storage.blobs.models.blobstates) parameter with the **Version** or **Snapshot** field. Versions and snapshots are listed from oldest to newest.
112111

113112
The following code example shows how to list blob versions.
114113

115-
```csharp
116-
private static void ListBlobVersions(BlobContainerClient blobContainerClient,
117-
string blobName)
118-
{
119-
// Call the listing operation, specifying that blob versions are returned.
120-
// Use the blob name as the prefix.
121-
var blobVersions = blobContainerClient.GetBlobs
122-
(BlobTraits.None, BlobStates.Version, prefix: blobName)
123-
.OrderByDescending(version => version.VersionId);
124-
125-
// Construct the URI for each blob version.
126-
foreach (var version in blobVersions)
127-
{
128-
BlobUriBuilder blobUriBuilder = new BlobUriBuilder(blobContainerClient.Uri)
129-
{
130-
BlobName = version.Name,
131-
VersionId = version.VersionId
132-
};
133-
134-
if ((bool)version.IsLatestVersion.GetValueOrDefault())
135-
{
136-
Console.WriteLine("Current version: {0}", blobUriBuilder);
137-
}
138-
else
139-
{
140-
Console.WriteLine("Previous version: {0}", blobUriBuilder);
141-
}
142-
}
143-
}
144-
```
114+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/CRUD.cs" id="Snippet_ListBlobVersions":::
145115

146116
## Resources
147117

articles/storage/blobs/versioning-enable.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: normesta
77

88
ms.service: storage
99
ms.topic: how-to
10-
ms.date: 01/25/2023
10+
ms.date: 02/14/2023
1111
ms.author: normesta
1212
ms.subservice: blobs
1313
ms.custom: devx-track-azurepowershell, devx-track-azurecli, engagement-fy23
@@ -107,6 +107,10 @@ To list a blob's versions in the Azure portal:
107107

108108
:::image type="content" source="media/versioning-enable/portal-list-blob-versions.png" alt-text="Screenshot showing how to list blob versions in the Azure portal":::
109109

110+
1. Toggle the **Show deleted versions** button to display soft-deleted versions. If blob soft delete is enabled for the storage account, then any soft-deleted versions that are still within the soft-delete retention interval will appear in the list.
111+
112+
:::image type="content" source="media/versioning-enable/portal-list-deleted-versions.png" alt-text="Screenshot showing how to list soft-deleted versions in Azure portal.":::
113+
110114
# [PowerShell](#tab/powershell)
111115

112116
To list a blob's versions with PowerShell, call the [Get-AzStorageBlob](/powershell/module/az.storage/get-azstorageblob) command with the `-IncludeVersion` parameter:
@@ -150,22 +154,6 @@ N/A
150154

151155
---
152156

153-
## Modify a blob to trigger a new version
154-
155-
The following code example shows how to trigger the creation of a new version with the Azure Storage client library for .NET, version [12.5.1](https://www.nuget.org/packages/Azure.Storage.Blobs/12.5.1) or later. Before running this example, make sure you have enabled versioning for your storage account.
156-
157-
The example creates a block blob, and then updates the blob's metadata. Updating the blob's metadata triggers the creation of a new version. The example retrieves the initial version and the current version, and shows that only the current version includes the metadata.
158-
159-
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/CRUD.cs" id="Snippet_UpdateVersionedBlobMetadata":::
160-
161-
## List blob versions with .NET
162-
163-
To list blob versions or snapshots with the .NET v12 client library, specify the [BlobStates](/dotnet/api/azure.storage.blobs.models.blobstates) parameter with the **Version** field.
164-
165-
The following code example shows how to list blobs version with the Azure Storage client library for .NET, version [12.5.1](https://www.nuget.org/packages/Azure.Storage.Blobs/12.5.1) or later. Before running this example, make sure you have enabled versioning for your storage account.
166-
167-
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/CRUD.cs" id="Snippet_ListBlobVersions":::
168-
169157
## Next steps
170158

171159
- [Blob versioning](versioning-overview.md)

0 commit comments

Comments
 (0)