工作角色localstorage的目录未发现异常

本文关键字:未发现 异常 角色 localstorage 工作 | 更新日期: 2023-09-27 18:06:22

在工作角色onStart事件上,我选择azure blobstorage上的json文件并将其下载到工作角色的localstorage.

  blockBlob2.DownloadToFile(RoleEnvironment.GetLocalResource("WorkerRoleStorage").RootPath, FileMode.Create);

我收到如下所示的System.IO.DirectoryNotFoundException .

System.IO.DirectoryNotFoundException was unhandled by user code
  HResult=-2147024893
  Message=Could not find a part of the path 'C:'Users'Arnab'AppData'Local'dftmp'Resources'006f5676-9c7e-4984-bbe7-83abd71f6726'directory'WorkerRoleStorage''.
  Source=mscorlib
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       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, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadToFile(String path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
       at WorkerRole1.WorkerRole.OnStart() in d:'uax'CollectorTest1'AzureCloudService1'WorkerRole1'WorkerRole.cs:line 64
       at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
       at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType roleType)
       at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
  InnerException: 

但是当我试图访问错误'Message'中显示的路径时,我能够在我的m/c上到达那里。

任何帮助都是真诚的感谢。

谢谢

工作角色localstorage的目录未发现异常

应该使用"本地存储资源",该目录是运行角色实例的虚拟机文件系统中的一个保留目录。在实例中运行的代码在需要写入或读取文件时可以访问本地存储资源。

MSDN参考:https://msdn.microsoft.com/en-us/library/azure/hh974419.aspx

相关文章:无法在windows azure上找到路径的一部分