所以我有这个应用程序,它需要从我不知道架构的表中查询 Azure 表存储中的实体。
1) 有没有办法用 Storageclient 包装器做到这一点?
2)我猜不是,所以我尝试使用 REST API,当我查询实体时总是得到 403 Forbidden。
这是我的代码。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("http://{0}.table.core.windows.net/Tables('{1}')", account,query));
request.UserAgent = " Microsoft ADO.NET Data Services";
request.KeepAlive = true;
request.Method = "GET";
request.Headers.Add("x-ms-version", "2009-09-19");
request.Headers.Add("x-ms-date", string.Format("{0} GMT", DateTime.UtcNow.ToString ("ddd, dd MMM yyyy HH:mm:ss")));
request.Headers.Add("Authorization", string.Format("SharedKey {0}:{1}", account, key));
request.Accept = "application/atom+xml,application/xml";
request.Headers.Add("Accept-Charset", "UTF-8");
request.Headers.Add("DataServiceVersion", "1.0;NetFx");
request.Headers.Add("MaxDataServiceVersion", "1.0;NetFx");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();