请提供有关创建控制台应用程序以从 Azure 表存储读取数据的良好文档。我按照 https://www.youtube.com/watch?v=z96fIv3RQBo 创建了一个示例控制台应用程序,如下所示。在运行控制台时,我看到"收到错误请求"错误:
class Program
{
const string StorageAccountName = "";
const string StorageAccountKey = "";
static void Main(string[] args)
{
var storageAccount = new CloudStorageAccount(new StorageCredentials(StorageAccountName, StorageAccountKey), false);
var tableaa = storageAccount.CreateCloudTableClient().GetTableReference("Table1");
var result = tableaa.ExecuteAsync(TableOperation.Retrieve<Person>("<partition-key>", "<row-key>"));
var entity = result.Result;
Console.WriteLine(entity);
}
}
class Person : TableEntity
{
private int customerID;
private string LocationAreaCode;
private string PersonnelSubAreaCode;
private string PersonStatusCode;
public void AssignRowKey()
{
this.RowKey = customerID.ToString();
}
public void AssignPartitionKey()
{
this.PartitionKey = "<partition-key";
}
}
Person 类中缺少无参数构造函数:
请按如下方式更改 Person 类:
class Person : TableEntity
{
private int customerID;
private string LocationAreaCode;
private string PersonnelSubAreaCode;
private string PersonStatusCode;
public Person()
{
}
//other code
}
有关更多详细信息,请参阅此官方文档。