Skip to content

Instantly share code, notes, and snippets.

@bitsmuggler
Created December 20, 2013 14:10
Show Gist options
  • Save bitsmuggler/8055316 to your computer and use it in GitHub Desktop.
Save bitsmuggler/8055316 to your computer and use it in GitHub Desktop.
Upload file to your Windows Azure Blob Storage (Requires Windows Azure Storage Package v3.0.1.0)
using System;
using System.IO;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
namespace AzureBlobstorageTest
{
internal class Program
{
private const string url = "<<your url>>";
private const string accountName = "<<your account>>";
private const string keyValue = "<<your key>>";
private const string containerName = "<<your container name>>";
private const string blobName = "<<your blob name>>";
private const string fileName = "<<file to upload>>";
private static void Main(string[] args)
{
var blobClient = new CloudBlobClient(new Uri(url, UriKind.Absolute), new StorageCredentials(accountName, keyValue));
var blobContainer = blobClient.GetContainerReference(containerName);
if (blobContainer.Exists())
{
var cloudBlockBlob = blobContainer.GetBlockBlobReference(blobName);
cloudBlockBlob.UploadFromFile(fileName, FileMode.OpenOrCreate);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment