【发布时间】:2021-07-22 03:09:46
【问题描述】:
连接到 Azure 存储时出现错误。 错误:重试 6 次后失败。 (不知道这样的主机。(shipfiles.blob.core.windows.net:443))
string downloadFilePath = @"C:\test.xlsx"; 尝试 {
string connectionString = "DefaultEndpointsProtocol=https;AccountName=;AccountKey=HulI9Usin8D/PgATIYW3FQHS9yyxCB+zLVQCAb4MWq0fEyU63SZIyr9JtzI0iy1K/2Nur0dWyCgeSrknSe/aA==;EndpointSuffix=core.windows.net";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
string containerName = "samplecontainer";
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
string filename = "TACSNTNA.xlsx";
BlobClient blobClient = containerClient.GetBlobClient(filename);
BlobDownloadInfo download = blobClient.Download();
using (FileStream downloadFileStream = new FileStream(downloadFilePath,FileMode.OpenOrCreate))
{
download.Content.CopyToAsync(downloadFileStream);
downloadFileStream.Close();
}
}
catch (Exception ex)
{
}
【问题讨论】:
-
如需了解如何配置代理,请参考docs.microsoft.com/en-us/dotnet/azure/sdk/…
-
我在我的机器上设置了代理。但它给了我同样的错误。
-
能否请您通过浏览器访问 azure blob?
-
我可以通过添加以下代码来使用它。 System.Environment.SetEnvironmentVariable("HTTPS_PROXY", "username:password@1.0.0.0:8080");
标签: azure asp.net-core .net-core azure-blob-storage