2017-09-25 107 views
0

我有這樣的一行代碼,使用Azure.ServiceRuntime.LocalResource類:C#MVC LocalResource在微軟Azure

LocalResource localResources = RoleEnvironment.GetLocalResource(fileName); 

當我試圖訪問具有此行它給了我下面的錯誤(控制器不是在同一個控制器的具體行動),本質上是一個403錯誤:

You do not have permission to view this directory or page. 

我不知道這應該如何對微軟Azure的工作與我的C#應用​​MVC5。我也嘗試添加一個Azure存儲帳戶(存儲帳戶 - blob,文件,表,隊列),但它仍然無法工作。我正在嘗試創建的文件是一個pdf文件。

有誰知道如何解決這個問題?

回答

0

按照LocalResource類的言論:

A local storage resource is a reserved directory in the file system of the virtual machine in which an instance of a role is running. To define a local storage resource for your hosted service, you must add a LocalResources element with LocalStorage elements to the ServiceDefinition.csdef file of the hosted service for each directory that you want to create.

所以,如果你想使用RoleEnvironment.GetLocalResource方法來獲取路徑,則必須用localStorage的元素添加LocalResources元素的的ServiceDefinition.csdef中的文件爲您要創建的每個目錄提供託管服務。

但是,如果您想要將創建的pdf文件添加到azure存儲帳戶的Blob文件。

您需要使用存儲庫來執行此操作。

您需要先在您的服務器上創建一個pdf文件,然後才能將文件上傳到azure存儲帳戶(例如:blob)。

有關如何使用存儲帳戶庫上傳文件的更多詳細信息,可以參考此article