Skip to content

Commit bf1f0d5

Browse files
authored
Merge pull request #234547 from pauljewellmsft/pauljewell-snapshot-version-rehydrate
Add samples for snapshots and versions
2 parents 748cca0 + 3cddf87 commit bf1f0d5

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

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

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Create and manage a blob snapshot in .NET
2+
title: Create and manage a blob snapshot with .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
@@ -10,10 +10,10 @@ ms.topic: how-to
1010
ms.date: 08/27/2020
1111
ms.subservice: blobs
1212
ms.devlang: csharp
13-
ms.custom: devx-track-csharp
13+
ms.custom: devx-track-csharp, devguide-csharp
1414
---
1515

16-
# Create and manage a blob snapshot in .NET
16+
# Create and manage a blob snapshot with .NET
1717

1818
A snapshot is a read-only version of a blob that's taken at a point in time. This article shows how to create and manage blob snapshots using the [Azure Storage client library for .NET](/dotnet/api/overview/azure/storage).
1919

@@ -29,10 +29,15 @@ To create a snapshot of a block blob, use one of the following methods:
2929
The following code example shows how to create a snapshot. Include a reference to the [Azure.Identity](https://www.nuget.org/packages/azure.identity) library to use your Azure AD credentials to authorize requests to the service. For more information about using the [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) class to authorize a managed identity to access Azure Storage, see [Azure Identity client library for .NET](/dotnet/api/overview/azure/identity-readme).
3030

3131
```csharp
32-
private static async Task CreateBlockBlobSnapshot(string accountName, string containerName, string blobName, Stream data)
32+
private static async Task CreateBlockBlobSnapshot(
33+
string accountName,
34+
string containerName,
35+
string blobName,
36+
Stream data)
3337
{
3438
const string blobServiceEndpointSuffix = ".blob.core.windows.net";
35-
Uri containerUri = new Uri("https://" + accountName + blobServiceEndpointSuffix + "/" + containerName);
39+
Uri containerUri =
40+
new Uri("https://" + accountName + blobServiceEndpointSuffix + "/" + containerName);
3641

3742
// Get a container client object and create the container.
3843
BlobContainerClient containerClient = new BlobContainerClient(containerUri,
@@ -89,12 +94,24 @@ The following code example shows how to delete a blob and its snapshots in .NET,
8994
await blobClient.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots, null, default);
9095
```
9196

92-
## Next steps
97+
## Copy a blob snapshot over the base blob
9398

94-
- [Blob snapshots](snapshots-overview.md)
95-
- [Blob versions](versioning-overview.md)
96-
- [Soft delete for blobs](./soft-delete-blob-overview.md)
99+
You can perform a copy operation to promote a snapshot over its base blob, as long as the base blob is in an online tier (hot or cool). The snapshot remains, but its destination is overwritten with a copy that can be read and written to.
100+
101+
The following code example shows how to copy a blob snapshot over the base blob:
102+
103+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CopySnapshot.cs" id="Snippet_CopySnapshot":::
97104

98105
## Resources
99106

100-
For related code samples using deprecated .NET version 11.x SDKs, see [Code samples using .NET version 11.x](blob-v11-samples-dotnet.md#create-a-snapshot).
107+
To learn more about managing blob snapshots using the Azure Blob Storage client library for .NET, see the following resources.
108+
109+
For related code samples using deprecated .NET version 11.x SDKs, see [Code samples using .NET version 11.x](blob-v11-samples-dotnet.md#create-a-snapshot).
110+
111+
[!INCLUDE [storage-dev-guide-resources-dotnet](../../../includes/storage-dev-guides/storage-dev-guide-resources-dotnet.md)]
112+
113+
### See also
114+
115+
- [Blob snapshots](snapshots-overview.md)
116+
- [Blob versions](versioning-overview.md)
117+
- [Soft delete for blobs](./soft-delete-blob-overview.md)

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,21 @@ The following code example shows how to list blob versions.
3535

3636
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/CRUD.cs" id="Snippet_ListBlobVersions":::
3737

38-
## See also
38+
## Copy a previous blob version over the base blob
39+
40+
You can perform a copy operation to promote a version over its base blob, as long as the base blob is in an online tier (hot or cool). The version remains, but its destination is overwritten with a copy that can be read and written to.
41+
42+
The following code example shows how to copy a blob version over the base blob:
43+
44+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CopyVersion.cs" id="Snippet_CopyVersion":::
45+
46+
## Resources
47+
48+
To learn more about managing blob versions using the Azure Blob Storage client library for .NET, see the following resources.
49+
50+
[!INCLUDE [storage-dev-guide-resources-dotnet](../../../includes/storage-dev-guides/storage-dev-guide-resources-dotnet.md)]
51+
52+
### See also
3953

4054
- [Blob versioning](versioning-overview.md)
4155
- [Enable and manage blob versioning](versioning-enable.md)

0 commit comments

Comments
 (0)