2
我正在使用Azure存储客户端将一些文件上载到Azure blob存储。该上传发生在本地机器中存储的dll
文件中。以下是我正在使用的代码。使用代理服务器上载Azure存储客户端库
public bool UploadBlob(byte[] fileContent, CloudStorageAccount account, string containerName, string blobName)
{
try
{
CloudBlobClient blobclient = account.CreateCloudBlobClient();
CloudBlobContainer container = blobclient.GetContainerReference(containerName);
container.CreateIfNotExist();
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);
HashSet<string> blocklist = new HashSet<string>();
foreach (FileBlock block in GetFileBlocks(fileContent))
{
if (ScanTool.mIsThreadStop)
return false;
ScanTool.mDocumentUploadedSize += block.Content.Length;
blob.PutBlock(
block.Id,
new MemoryStream(block.Content, true),
null
);
blocklist.Add(block.Id);
}
blob.PutBlockList(blocklist);
blob.FetchAttributes();
return blob.Properties.Length == fileContent.Length;
}
catch (Exception e) {
Log.WriteErrorLog(e, "UploadBlob at AzureBlobUtilCS");
throw new System.Net.WebException();
}
}
我打电话上述上传方法如下所示,抛出“代理身份验证失败”异常在下面的代码
try
{
CloudBlobContainer container = AzureHelper.GetContainer(containerName, accountName, accountKey);
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(AzureHelper.GetConnectionString(accountName, accountKey));
return UploadBlob(fileContent, storageAccount, containerName, blobName);
}catch(Exception e)
{
WriteInformationMessage("exception at UploadBlob11 =" + e.Message);
return false;
}
这个问题在我的客户网站的一次邂逅,他是说他们在他们的本地网络中有一个代理。代理名称是bluecoat proxy SG 900
如何摆脱此?
你可以尝试在app/web config文件中设置代理设置:https://msdn.microsoft。 COM/EN-US /库/ kd3cf2ex(v = vs.110)的.aspx。 –
请按照Gaurav上面的说明进行操作。 :) –
@Zhaoxing Lu有任何使用Azure存储客户端库的身份验证代理的方式 –