Skip to content

Commit 80dd218

Browse files
Add example
1 parent f06ab3a commit 80dd218

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

articles/storage/files/storage-dotnet-how-to-use-files.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,27 @@ You can configure the file share properties using the [FileShareData](/dotnet/ap
461461
>[!NOTE]
462462
> To perform the register operation, you need permissions for the following Azure RBAC action: Microsoft.Storage/register/action. This permission is included in the Contributor and Owner built-in roles.
463463
464+
### Example: List file shares and snapshots using the Azure Storage management library
465+
466+
The following code example shows how to list file shares and snapshots in a storage account:
467+
468+
```csharp
469+
// Iterate over a collection of file shares and list them along with any snapshots
470+
string expand = "snapshots";
471+
await foreach (FileShareResource shareResource in fileService.GetFileShares().GetAllAsync(expand: expand))
472+
{
473+
// Call operations on the file share resource
474+
475+
// For this demo, print out the resource name and snapshot information
476+
FileShareData resourceData = shareResource.Data;
477+
Console.WriteLine($"Resource name: {resourceData.Name}");
478+
if (resourceData.SnapshotOn.HasValue)
479+
{
480+
Console.WriteLine($"Snapshot created: {resourceData.SnapshotOn}");
481+
}
482+
}
483+
```
484+
464485
## Related content
465486
466487
For more information about Azure Files, see the following resources:

0 commit comments

Comments
 (0)