I want to show all file share from storage account. I have storage account dropdown so whenever user will select particular storage account name i want to fetch all file share name associated with selected storage account. I want any Fluent API or REST API.
Asked
Active
Viewed 436 times
1
-
Can .NET SDK or REST API both meet your requirements? – Cindy Pau Jun 02 '21 at 10:10
-
@Bowman Zhu currently In my project i am using azure fluent api but using that i am not able to fetch details of azure file share so I am finding any another way.So please help me on this. – DnyaneshSurya Jun 02 '21 at 10:15
1 Answers
1
using System;
using System.Threading.Tasks;
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;
namespace ConsoleApp5
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("xxxxxxxxxxxxxxxxxxxxx");
string connectionString = "DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx;EndpointSuffix=core.windows.net";
ShareServiceClient ssc = new ShareServiceClient(connectionString);
foreach (ShareItem item in ssc.GetShares())
{
Console.WriteLine(item.Name);
}
}
}
}
And this is the REST API:
https://learn.microsoft.com/en-us/rest/api/storageservices/list-shares
.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.6.2" />
</ItemGroup>
</Project>

Cindy Pau
- 13,085
- 1
- 15
- 27
-
thank you for the reply but for ShareServiceClient class which nuget package should i install currently i have install Install-Package Azure.Storage.Files.Shares -Version 12.6.2 but not working – DnyaneshSurya Jun 02 '21 at 12:47
-
-
The type or namespace sound not be found . Are you missing assembly reference . But I installed properly and added reference also Azure.Storage.Files.Shares but still getting. – DnyaneshSurya Jun 02 '21 at 14:11
-
-
1Thank you very much........It's working now after build the project. – DnyaneshSurya Jun 02 '21 at 17:43
-
How to get Azure Storage Account Key (connectionString) any any .net sdk available for this also. – DnyaneshSurya Jun 03 '21 at 07:20
-
@DnyaneshSurya Azure manage sdk should be able to do this. Do you mind to post a new question? Ask another question in the comment doesn't match community norms. – Cindy Pau Jun 03 '21 at 07:40