Giter Club home page Giter Club logo

azure-sdk-for-net-storage-blob-upload-download's Introduction

page_type languages products description urlFragment
sample
csharp
azure
azure-storage
dotnet-core
How to upload and download blobs from Azure Blob Storage with .NET.
upload-download-blobs-net

How to upload and download blobs from Azure Blob Storage with .NET

SDK Versions

In this sample, you will find the following folders:

  • v11 - references Storage Blob SDK v11
  • v12 - references Storage Blob SDK v12

Prerequisites

To complete this tutorial:

If you don't have an Azure subscription, create a free account before you begin.

Create a Storage Account using the Azure Portal

Step 1 : Create a new general-purpose Storage Account to use for this tutorial.

  • Go to the Azure Portal and log in using your Azure account.
  • Select New > Storage > Storage account.
  • Select your Subscription.
  • For Resource group, create a new one and give it a unique name.
  • Enter a name for your storage Account.
  • Select the Location to use for your Storage Account.
  • Set Account kind to StorageV2(general purpose v2).
  • Set Performance to Standard.
  • Set Replication to Locally-redundant storage (LRS).
  • Set Secure transfer required to Disabled.
  • Check Review + create and click Create to create your Storage Account.

Step 2 : Copy and save Connection string.

After your Storage Account is created. Click on it to open it. Select Settings > Access keys > Key1/key, copy the associated Connection string to the clipboard, then paste it into a text editor for later use.

Put the connection string in an environment variable

This solution requires a connection string be stored in an environment variable securely on the machine running the sample. Follow one of the examples below depending on your operating system to create the environment variable. If using Windows close your open IDE or shell and restart it to be able to read the environment variable.

Linux

export AZURE_STORAGE_CONNECTIONSTRING="<YourConnectionString>"

Windows

setx AZURE_STORAGE_CONNECTIONSTRING "<YourConnectionString>"

At this point, you can run this application. It creates its own file to upload and download, and then cleans up after itself by deleting everything at the end.

Run the application

First, clone the repository on your machine:

git clone https://github.com/Azure-Samples/azure-sdk-for-net-storage-blob-upload-download.git

Then, switch to the appropriate folder:

cd v11

or

cd v12

Finally, run the application with the dotnet run command.

dotnet run

This sample shows how to do following operations of Storage Blobs

  • Create a Storage Account using the Azure Portal.
  • Create a container.
  • Upload a file to block blob.
  • List blobs.
  • Download a blob to file.
  • Delete a blob.
  • Delete the container.

More information

The Azure Storage documentation includes a rich set of tutorials and conceptual articles, which serve as a good complement to the samples.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

azure-sdk-for-net-storage-blob-upload-download's People

Contributors

georgewallace avatar jongio avatar mhopkins-msft avatar microsoftopensource avatar msftgits avatar robinsh avatar supernova-eng avatar tamram avatar tzhanl avatar wantedfast avatar

Watchers

 avatar

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.