我需要从Azure的Blob存储文件复制到我的Azure中的“内容”文件夹托管网站,而我努力使这项工作! 任何帮助将是非常赞赏。 代码工作在我的本地服务器上的罚款,但在Azure托管时失败。
这里是我的功能:
public bool CopyFromAzure(string myContainer, string fileName, string filePath)
{
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference(myContainer);
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName);
try
{
// Save blob contents to a file.
// --> here is where an error happens !! on System.IO.File.Create
// The value of "filePath" is: F:\sitesroot\0\Content\tmp\file_2cfe0a3d-fa7a-4ab4-a665-cdebd90567d4.pdf
using(FileStream fs= System.IO.File.Create(@filePath))
{
blockBlob.DownloadToStream(fs);
}
}
catch (Exception e)
{
return false;
}
return true;
}
问:可以将此链接到安全的喜好在Azure中或在我的网站配置?
thxs