Skip to content

Commit ca75e9c

Browse files
authored
Merge pull request #115419 from normesta/normesta-snippets
Adding snippet links for snapshot scenarios
2 parents 0a8df04 + 87024ab commit ca75e9c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

articles/storage/blobs/soft-delete-enable.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: tamram
77

88
ms.service: storage
99
ms.topic: conceptual
10-
ms.date: 05/11/2020
10+
ms.date: 05/15/2020
1111
ms.author: tamram
1212
ms.subservice: blobs
1313
---
@@ -133,7 +133,21 @@ block_blob_service.set_blob_service_properties(
133133
delete_retention_policy=DeleteRetentionPolicy(enabled=True, days=7))
134134
```
135135

136-
# [.NET](#tab/net)
136+
# [.NET v12 SDK](#tab/dotnet)
137+
138+
To enable soft delete, update a blob client's service properties:
139+
140+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/DataProtection.cs" id="Snippet_EnableSoftDelete":::
141+
142+
To recover blobs that were accidentally deleted, call Undelete on those blobs. Remember that calling **Undelete**, both on active and soft deleted blobs, will restore all associated soft deleted snapshots as active. The following example calls Undelete on all soft deleted and active blobs in a container:
143+
144+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/DataProtection.cs" id="Snippet_RecoverDeletedBlobs":::
145+
146+
To recover to a specific blob version, first call Undelete on a blob, then copy the desired snapshot over the blob. The following example recovers a block blob to its most recently generated snapshot:
147+
148+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/DataProtection.cs" id="Snippet_RecoverSpecificBlobVersion":::
149+
150+
# [.NET v11 SDK](#tab/dotnet11)
137151

138152
To enable soft delete, update a blob client's service properties:
139153

@@ -149,7 +163,7 @@ serviceProperties.DeleteRetentionPolicy.RetentionDays = RetentionDays;
149163
blobClient.SetServiceProperties(serviceProperties);
150164
```
151165

152-
To recover blobs that were accidentally deleted, call Undelete on those blobs. Remember that calling **Undelete Blob**, both on active and soft deleted blobs, will restore all associated soft deleted snapshots as active. The following example calls Undelete on all soft deleted and active blobs in a container:
166+
To recover blobs that were accidentally deleted, call Undelete on those blobs. Remember that calling **Undelete**, both on active and soft deleted blobs, will restore all associated soft deleted snapshots as active. The following example calls Undelete on all soft deleted and active blobs in a container:
153167

154168
```csharp
155169
// Recover all blobs in a container
@@ -173,7 +187,7 @@ IEnumerable<IListBlobItem> allBlobVersions = container.ListBlobs(
173187
CloudBlockBlob copySource = allBlobVersions.First(version => ((CloudBlockBlob)version).IsSnapshot &&
174188
((CloudBlockBlob)version).Name == blockBlob.Name) as CloudBlockBlob;
175189
blockBlob.StartCopy(copySource);
176-
```
190+
```
177191

178192
---
179193

0 commit comments

Comments
 (0)