GithubHelp home page GithubHelp logo

azureblobsas's Introduction

AzureBlobSAS

App.config

  <appSettings>
    <add key="SasUri" value="https://{accountname}.blob.core.windows.net/{container}?{blob access token}&amp;comp=list&amp;restype=continer"/>
  </appSettings>

PushBlob

  string sasUristring = ConfigurationManager.AppSettings.Get("SasUri");
  string localDownloadPath = @"C:\data\azure";

  Uri sasUri = new Uri(sasUristring);
  BlobContainerClient container = new BlobContainerClient(sasUri);
  
  /* or 
  string containerUri = "https://{accountname}.blob.core.windows.net/{container}";
  string signature = "sp=racwdl&amp;st=2021-09-01T12:18:54Z&amp;se=2021-09-30T20:18:54Z&amp;spr=https&amp;sv=2020-08-04&amp;sr=c&amp;sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  
  BlobContainerClient container = new BlobContainerClient(containerUri, signature);
  */
  
  Task task;
  
  string localFilePath = @"G:\data\AAPL.csv";
  //A path start from "/" e.g. "/folder_A/folder_B/blob_x.txt"
  string blobName = @"/data/stock/AAPL.csv"; 
  bool overwrite = true;
  
  task = PushBlob.UploadAsync(container, @"C:\data\AAPL.csv", overwrite, @"/data/stock/AAPL.csv");
  Console.WriteLine("s task.Wait();");
  task.Wait();
  Console.WriteLine("f task.Wait();");
  
  Console.ReadLine();

PullBlob

  string sasUristring = ConfigurationManager.AppSettings.Get("SasUri");
  string localDownloadPath = @"C:\data\azure";

  Uri sasUri = new Uri(sasUristring);
  BlobContainerClient container = new BlobContainerClient(sasUri);

  /* or 
  string containerUri = "https://{accountname}.blob.core.windows.net/{container}";
  string signature = "sp=racwdl&amp;st=2021-09-01T12:18:54Z&amp;se=2021-09-30T20:18:54Z&amp;spr=https&amp;sv=2020-08-04&amp;sr=c&amp;sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  
  BlobContainerClient container = new BlobContainerClient(containerUri, signature);
  */
  
  Task task;
  
  task = PullBlob.DownloadBlobsHierarchicalListing(container, localDownloadPath, DateTime.MinValue);
  Console.WriteLine("s task.Wait();");
  task.Wait();
  Console.WriteLine("f task.Wait();");

  Console.ReadLine();

azureblobsas's People

Contributors

onedollor avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

yruihawaii

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.