Goo*_*ber 2 c# azure azure-storage azure-storage-blobs azure-table-storage
摘要
简单的代码示例
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 = "Walter@contoso.com";
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() { }
}
Run Code Online (Sandbox Code Playgroud)
问题
1.没有表与blob或容器不同.容器用于容纳blob,如果blob是文件,则将它们视为驱动器.
表具有特定功能,例如指定影响性能的分区和键的功能.
2. Azure管理界面不提供用于处理表的界面,您只需在仪表板和监视器选项卡中查看指标即可.
对于管理,我建议您通过Cerebrata获取Azure Management Studio,或者如果您想要免费查看Azure Storage Explorer.两者都可以让您更好地管理表格.
3.表结构是从您不需要创建或管理列的实体生成的,甚至可以在同一个表中的实体之间改变列(尽管我个人不喜欢这个功能).