Created
September 26, 2013 18:43
-
-
Save robertgreiner/6718704 to your computer and use it in GitHub Desktop.
How to write text to a CloudBlockBlob in Windows Azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AzureStorageAccount")); | |
var blobClient = storageAccount.CreateCloudBlobClient(); | |
var container = blobClient.GetContainerReference(containerName); | |
container.CreateIfNotExists(); | |
CloudBlockBlob blob = container.GetBlockBlobReference(fileName); | |
blob.DeleteIfExists(); | |
var options = new BlobRequestOptions() | |
{ | |
ServerTimeout = TimeSpan.FromMinutes(10) | |
}; | |
using (var stream = new MemoryStream(Encoding.Default.GetBytes(text), false)) | |
{ | |
blob.UploadFromStream(stream, null, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment