Reputation: 13508
Summary
Simple Code Example
static void Main(string[] args)
{
try
{
CloudStorageAccount storageAccount =
CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=<your_storage_name>;AccountKey=<your_account_key>");
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("people");
table.CreateIfNotExists();
CustomerEntity customer1 = new CustomerEntity("Harp", "Walter");
customer1.Email = "[email protected]";
customer1.PhoneNumber = "425-555-0101";
// Create the TableOperation that inserts the customer entity.
var insertOperation = TableOperation.Insert(customer1);
// Execute the insert operation.
table.Execute(insertOperation);
// Read storage
TableQuery<CustomerEntity> query =
new TableQuery<CustomerEntity>()
.Where(TableQuery.GenerateFilterCondition("PartitionKey",
QueryComparisons.Equal, "Harp"));
var list = table.ExecuteQuery(query).ToList();
}
catch (StorageException ex)
{
// Exception handling here.
}
}
public class CustomerEntity : TableEntity
{
public string Email { get; set; }
public string PhoneNumber { get; set; }
public CustomerEntity(string lastName, string firstName)
{
PartitionKey = lastName;
RowKey = firstName;
}
public CustomerEntity() { }
}
Questions
Upvotes: 2
Views: 10683
Reputation: 29668
1. No a table isn't the same as a blob or container. A container is used to house blobs, think of them as drives if blobs are the files.
Tables have specific features such as the ability to specify partitions and keys which affects performance.
2. The Azure management interface doesn't provide an interface for working with tables, you can just see metrics in the dashboard and monitor tabs.
For management I recommend you get the Azure Management Studio by Cerebrata, or if you want something free look at the Azure Storage Explorer. Both let you manage tables a bit better.
3. The table structure is generated from your entity you don't need to create or manage columns, you can even vary columns across entities in the same table (though I personally don't like this feature).
Upvotes: 7