Home > Software engineering >  Delete an Azure File Share Snapshot with C#
Delete an Azure File Share Snapshot with C#

Time:07-27

I cannot find an example of deleting an Azure File Shares Snapshot using SDK 12 in C#. There are a ton of examples for SDK 11 but none, that I can find, for SDK 12. If anyone has a good example I would appreciate it very much!

CodePudding user response:

Please try this code. Basically you need to make use of ShareClient.WithSnapshot(String) to get access to a Share's snapshot.

var connectionString =
    "DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=account-key";
var shareName = "test";
var snapshot = "2022-07-26T13:49:01.0000000Z";
ShareServiceClient shareserviceclient = new ShareServiceClient(connectionString);
ShareClient shareClient = shareserviceclient.GetShareClient(shareName).WithSnapshot(snapshot);
shareClient.Delete();
  • Related