Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wcf Windows Azure驱动器-访问被拒绝异常_Wcf_Azure_Azure Storage_Azure Storage Blobs - Fatal编程技术网

Wcf Windows Azure驱动器-访问被拒绝异常

Wcf Windows Azure驱动器-访问被拒绝异常,wcf,azure,azure-storage,azure-storage-blobs,Wcf,Azure,Azure Storage,Azure Storage Blobs,我正在尝试编写一个测试WCF服务,将图像文件写入Azure驱动器存储: 以下是我编写的代码: var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")); blobStorage = storageAccount.CreateCloudBlobClient();

我正在尝试编写一个测试WCF服务,将图像文件写入Azure驱动器存储:

以下是我编写的代码:

            var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
            blobStorage = storageAccount.CreateCloudBlobClient();

            CloudBlobContainer container = blobStorage.GetContainerReference("mydrives");
            container.CreateIfNotExist();

            CloudPageBlob pageBlob = container.GetPageBlobReference("myvhd");
            CloudDrive drive = new CloudDrive(pageBlob.Uri, storageAccount.Credentials);

            try
            {
                drive.Create(100);
                driveLetter = drive.Mount(0, DriveMountOptions.None);
                var fileExtension = Path.GetExtension(file.FileName);
                var fileName = string.Format("{0:10}_{1}{2}", DateTime.Now.Ticks, Guid.NewGuid(), fileExtension);
                File.WriteAllBytes(driveLetter + "\\" + fileName, file.FileStream);
            }
            catch (CloudDriveException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
FileStream是我从Silverlight客户端获得的字节数组

当我在本地运行该代码时,它可以完美地工作。我甚至可以看到使用storage emulator viewer上传的驱动器blob和图像

但一旦我将其发布到云端并运行它,就会出现以下异常:

<InnerException i:nil="true"/><Message>Access to the path 'd:\1634586886770888071_aa98357b-888d-4dde-a231-1ca5d5c73b49.jpeg' is denied.</Message><StackTrace>   
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)&#xD;
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)&#xD;
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)&#xD;
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)&#xD;
       at System.IO.File.WriteAllBytes(String path, Byte[] bytes)&#xD;
       at ProcessService.FileService.UploadDCMToDrive(FileToTransfer file) in C:\Users\Vinod\Desktop\TestAzure_Vinod\ProcessService\FileService.svc.cs:line 68&#xD;
       at SyncInvokeUploadDCMToDrive(Object , Object[] , Object[] )&#xD;
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)&#xD;
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.UnauthorizedAccessException</Type>
现在我得到了这个错误:

Could not find a part of the path 'd:\images\test.jpeg

这真的很奇怪:-(

奇怪。你不应该使用驱动器D:--它是为Azure的Windows分区保留的。好的,我将使用DirectoryInfo类在根文件夹中创建一个文件夹。让我看看发生了什么。更新了原始帖子。在根目录下创建文件夹后,我收到了另一个错误。奇怪的是Azure不应该提供驱动器D:。是否有多个实例试图同时写入驱动器?好的,一个驱动器只能同时从一个实例进行写访问。
Could not find a part of the path 'd:\images\test.jpeg