title: Saving a datatable to an Azure container
body: <p>I have a need to archive data in a SQL Server table into an Azure container.</p>
  
  <p>The container is called Core-Backups and I connect to the container like so:</p>
  
  <pre><code>CloudStorageAccount storageAccount = CloudStorageAccount.Parse("snip");
  CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
  CloudBlobContainer container = blobClient.GetContainerReference("Core-Backups");
  </code></pre>
  
  <p>I would like the data I am archiving to go into a folder structure like</p>
  
  <pre><code>tablename/year/month/day/hour
  </code></pre>
  
  <p>And I have some questions</p>
  
  <pre><code>1. Do I need to create all of the folder structure first, or does Azure create it when I upload content? Right now my container is empty
  
  2. Is there a standard way to save a datatable to an Azure blob?
  </code></pre>
  
  <p>For a test I tried the following code to upload a text file into an example of the folder structure I want but it failed with a {"The remote server returned an error: (400) Bad Request."}</p>
  
  <pre><code>CloudBlobContainer container = blobClient.GetContainerReference("Core-Backups");
  CloudBlockBlob blob = container.GetBlockBlobReference("table1/2017/04/24/9/file1.txt");
  blob.UploadText("lorem ipsum");
  </code></pre>
  
  <p>Edit: I just read that containers must follow DNS rules, so I changed the GetContainerReference line to "core-backups" and it worked.</p>
  
  <p>However question 2 remains, is there a recommended way to upload a datatable?</p>