Search code examples
azureazure-storage

Simplest Azure Storage Manipulation possible


I have the need to integrate some blob storage into an existing ASP.NET Mvc site

my hope is to be able to just add some references and then just do puts and gets

but I cannot find any simple example for how to do this (that hasn't been deprecated to the point it no longer works)

I have tried using StorageClient but CreateCloudBlobClient() doesn't seem to work.


Solution

  • Windows Azure Platform Training Kit has a guestbok demo that shows how to do that, its simple as:

    // upload the image to blob storage
    CloudBlobContainer container = blobStorage.GetContainerReference("guestbookpics");
    string uniqueBlobName = string.Format("image_{0}.jpg", Guid.NewGuid().ToString());
    CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
    blob.Properties.ContentType = FileUpload1.PostedFile.ContentType;
    blob.UploadFromStream(FileUpload1.FileContent);
    

    You can download it at: http://www.microsoft.com/downloads/details.aspx?FamilyID=413e88f8-5966-4a83-b309-53b7b77edf78&displaylang=en