Question

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.

Was it helpful?

Solution

To track your requests through Fiddler, just change your endpoint from:

http://127.0.0.1:10000

to

http://ipv4.fiddler:10000

Also you don't need the defaultProxy setting in your app.config file. If you're keeping it there, then change the proxyaddress from http://ipv4.fiddler to http://127.0.0.1:8888. So your app.config file setting would look something like:

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

This is how storage client library does it (https://github.com/WindowsAzure/azure-sdk-for-net/blob/master/microsoft-azure-api/Services/Storage/Lib/Common/CloudStorageAccount.cs - God bless Windows Azure team for making their code available on 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"));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top