1

As a sandbox application i wrote a console app which will call RestApi for storage services.The app is running as expected and i can see calls made by application in Fiddler.I wrote this sandbox so that i could specifically use Rest API calls.

The point i am stuck is how to see REST calls made by my application against storage emulator in Fiddler. I know if i am using storage client library (azure SDK) then could have used following

UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://ipv4.fiddler

I tried setting the Proxy on the HttpWebRequest but that is also not helping me.Following i the excerpt from my code.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
WebRequest.DefaultWebProxy = new WebProxy("http://ipv4.fiddler");

or

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
request.Proxy = new WebProxy("http://ipv4.fiddler");

or

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
request.Proxy = new WebProxy("127.0.0.1",8888);

also tried setting up this in app.config like

 <system.net>
    <defaultProxy>
      <proxy
              proxyaddress="http://ipv4.fiddler"
              bypassonlocal="False" />
    </defaultProxy>
  </system.net>

but none seems to be working for me. Again just to be clear about my question, app is running fine for me both for storage emulator and My subscription. Only issue is that i cant see call in Fiddler if executed against storage emulator.

Thanks.

4

1 回答 1

2

要通过 Fiddler 跟踪您的请求,只需将您的端点更改为:

http://127.0.0.1:10000

http://ipv4.fiddler:10000

此外,您不需要defaultProxyapp.config 文件中的设置。如果您将其保留在那里,则将proxyaddressfrom更改http://ipv4.fiddlerhttp://127.0.0.1:8888. 所以你的 app.config 文件设置看起来像:

<system.net>
  <defaultProxy>
    <proxy usesystemdefault="False"
           proxyaddress="http://127.0.0.1:8888"
           bypassonlocal="False" />
  </defaultProxy>
</system.net>

这就是存储客户端库的工作方式(https://github.com/WindowsAzure/azure-sdk-for-net/blob/master/microsoft-azure-api/Services/Storage/Lib/Common/CloudStorageAccount.cs - God祝福 Windows Azure 团队在 Github 上提供他们的代码)!

internal static CloudStorageAccount GetDevelopmentStorageAccount(Uri proxyUri)
{
    if (proxyUri == null)
    {
        return DevelopmentStorageAccount;
    }

    string prefix = proxyUri.Scheme + "://" + proxyUri.Host;

    return new CloudStorageAccount(
        new StorageCredentials(DevstoreAccountSettingString, DevstoreAccountKey),
        new Uri(prefix + ":10000/devstoreaccount1"),
        new Uri(prefix + ":10001/devstoreaccount1"),
        new Uri(prefix + ":10002/devstoreaccount1"));
}
于 2013-08-07T09:07:01.207 回答