c# - 在代理后面连接到 Azure Batch - 操作返回无效状态代码 'Forbidden'

标签 c# azure proxy

我已设置一个 Azure Batch 帐户,并尝试使用此处的 C# HelloWorld 示例,

https://github.com/Azure/azure-batch-samples

在 AccountSettings.settings 中填写批处理和存储帐户详细信息后,如果我位于公司网络之外(位于代理服务器后面),则效果很好。但是,当我在代理服务器后面使用完全相同的代码时,

BatchException: Operation returned an invalid status code 'Forbidden'

并在控制台输出以下内容,

C:\Source\Scratch\Azure-batch-samples\CSharp\GettingStarted\01_HelloWorld\bin\Debug>HelloWorld.exe
Running with the following settings:
-------------------------------------
PoolId = HelloWorld-Pool
PoolTargetNodeCount = 2
PoolOSFamily = 4
PoolNodeVirtualMachineSize = small
ShouldDeleteJob = True

BatchAccountName = <censored>
BatchAccountKey = <censored>
BatchServiceUrl = <censored>
StorageAccountName = <censored>
StorageAccountKey = <censored>
StorageServiceUrl = <censored>

Deleting job: HelloWorldJob-809362-20180126-143309
Microsoft.Azure.Batch.Common.BatchException: Operation returned an invalid status code 'Forbidden' ---> Microsoft.Azure.
Batch.Protocol.Models.BatchErrorException: Operation returned an invalid status code 'Forbidden'
   at Microsoft.Azure.Batch.Protocol.JobOperations.<DeleteWithHttpMessagesAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

<..snip..>

Request Information
ClientRequestId:
RequestId:d8b9fcc6-b32d-437c-a8af-7d44d6df486d
HttpStatusCode:Forbidden
StatusMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly
 including the signature.


Error Code = AuthenticationFailed, Lang=en-US, Message = Server failed to authenticate the request. Make sure the value
of Authorization header is formed correctly including the signature.
RequestId:d8b9fcc6-b32d-437c-a8af-7d44d6df486d
Time:2018-01-26T13:33:13.9958126Z
Additional Values:
Error Details key=AuthenticationErrorDetail value=The MAC signature found in the HTTP request 'k4mfqD3FP6FL2nWLgR3E6AxRp
JJAse9vRW1qVOnn1K0=' is not the same as any computed signature. Server used following string to sign: 'DELETE

有谁知道这里发生了什么吗?

最佳答案

似乎有一个very similar issue仅影响 .NET Core,但已在 7.0.1 中修复,我假设您使用的是 8.0.1?

我要做的第一件事是验证(使用 Fiddler 或 Wireshark)流量确实通过您认为的代理。

如果没有,可能值得尝试 BatchClient需要 BatchServiceClient 的 ctor (通过传入 BatchServiceClient 并根据需要设置 HttpClientHandler 属性来创建 Proxy 的实例)。

如果失败 - 您实际上需要从公司代理后面访问批处理服务吗?我的猜测是,无论您实际想要对批处理服务执行什么操作,都将封装在 API 或 Web 应用程序中,而这些应用程序本身将部署到 Azure - 因此不需要 HTTP 代理!

关于c# - 在代理后面连接到 Azure Batch - 操作返回无效状态代码 'Forbidden',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48462402/

相关文章:

c# - C# 引用类型在传递给方法时会分配新内存吗?

azure - 当我不使用 www 时找不到网络应用程序

python Mechanize 代理问题

c# - 我的 C# 程序导致其他计算机出现 APPCRASH

C#异步IO : Is there a way of ensuring ordering of tasks?

c# - ClassName<T =""> 的含义和使用方法

flutter - 由于 webview,使用 flutter aad_oauth 进行 Google 登录不起作用

c# - Azure 计算模拟器中的内部端口冲突

c# - 从默认网络代理获取 URI

Python socket.accept() 没有收到任何连接请求