1

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.

DnyaneshSurya
  • 187
  • 1
  • 1
  • 14
  • 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 Answers1

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