我已设置一个 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/