Reputation: 5
I'm new to Azure storage.I want to create a container and also a blob(XML file or whatever) in it. Here is the code for creating a container but I'm having trouble how to create XML (not upload form local).
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("XXXXXXXX");
// Create the container if it doesn't already exist.
container.CreateIfNotExists();
Anyone can provide some code example would be great!!
Thanks a lot!
Upvotes: 0
Views: 3171
Reputation: 244
Once you are done with the above code to get reference of a Container, do the below:
//Create reference to a Blob that May or Maynot exist under the container
CloudBlockBlob blockBlob = container.GetBlockBlobReference("something.xml");
// Create or overwrite the "something.xml" blob with contents from a string
string s = "your XML";
await blockBlob.UploadTextAsync(s);
Upvotes: 1