gpt4 book ai didi

azure - 从控制台应用程序针对存储模拟器调用 Rest API,请求未显示在 fiddler 中

转载 作者:行者123 更新时间:2023-12-03 01:56:08 24 4
gpt4 key购买 nike

作为沙箱应用程序,我编写了一个控制台应用程序,它将调用 RestApi 来获取存储服务。该应用程序按预期运行,我可以在 Fiddler 中看到应用程序进行的调用。我编写了这个沙箱,以便我可以专门使用 Rest API 调用.

我遇到的问题是如何查看我的应用程序对 Fiddler 中的存储模拟器进行的 REST 调用。 我知道如果我使用存储客户端库(azure SDK)那么可以使用以下

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

我尝试在 HttpWebRequest 上设置代理,但这对我也没有帮助。以下是我的代码摘录。

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

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

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

还尝试在 app.config 中进行设置,例如

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

但似乎没有一个对我有用。再次澄清我的问题,应用程序对于存储模拟器和我的订阅来说都运行良好。唯一的问题是,如果针对存储模拟器执行,我看不到 Fiddler 中的调用。

谢谢。

最佳答案

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

http://127.0.0.1:10000

http://ipv4.fiddler:10000

此外,您不需要 app.config 文件中的 defaultProxy 设置。如果您将其保留在那里,请将 proxyaddresshttp://ipv4.fiddler 更改为 http://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 - 上帝保佑 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"));
}

关于azure - 从控制台应用程序针对存储模拟器调用 Rest API,请求未显示在 fiddler 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18097161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com