문제

So I have this app which needs to query entities from the Azure Tables storage from tables I don't know the schema of.

1) Is there a way I can do that with the Storageclient wrapper?
2) I'm guessing no, so I tried with the REST API and I always get the 403 Forbidden when I query for the entities.

This is my code.

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();
도움이 되었습니까?

해결책

Yes, you can do it. There is a good entry on how to at: http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/481afa1b-03a9-42d9-ae79-9d5dc33b9297/

It gives a good code example so I won't elaborate on it. This code is pretty much what I use in my AzureTableQuery project to find out the properties of an entity. If you look at the code, check out the GenericTableContext.cs and GenericEntity.cs classes

다른 팁

다음 One-Liner는 파일 타임 스탬프 (단일 단위), 파일 크기 (바이트 단위) 및 파일 이름을 CSV 행 세트로 출력합니다.

>csvfile.txt (FOR %R IN (*.sql *.xep *.aspx *.dll *.gif) DO @ECHO "%~tR";%~zR;"%~nxR")
.

참고 : 이것은 명령 프롬프트에서 직접 실행되도록되어 있습니다.이것을 배치 스크립트에 넣으려면 모든 % 문자를 두 배로 늘리십시오.

My initial problem was due to the fact that my Autorization header was not right.
I was just adding the key and there's actually a few thing you need to do with the key, sign a string and add that to the Autorization header.
More info here.

So why did I mark @Jason's answer as valid? Because my assumptions were wrong. There is a way to query entities in your Azure Tables even if you don't know the schema of your tables. And Jason's post showed my the way.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top