0

azure blob から azure localstorage にファイルをダウンロードしようとすると、「パス 'C:\Resources\directory....' へのアクセスが拒否されました。回避策として、power を持つ statup タスクを追加しました」というメッセージが表示されます。許可を有効にするための shell コマンド. しかし、この後、私の Web ロールは開始に時間がかかっていることが判明し、最終的に開始されました. しかし、それに書き込もうとすると、まだアクセス拒否エラー メッセージが表示され.ます. この問題を解決するための提案を感謝します.

また、powershell スクリプトのエンコーディングを Unicode (署名なしの UTF-8) - コードページ 65001 に変更しようとしました。でも運がない。助けてください

ここに私の StartUp.Cmd ファイルがあります

    @echo off


REM   Attempt to set the execution policy by using PowerShell version 2.0 syntax.
PowerShell -Version 2.0 -ExecutionPolicy Unrestricted .\fixfolderaccess.ps1 >> "%TEMP%\StartupLog.txt" 2>&1

IF %ERRORLEVEL% EQU -393216 (
   REM   PowerShell version 2.0 isn't available. Set the execution policy by using the PowerShell version 1.0 calling method.

   PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
   PowerShell .\fixfolderaccess.ps1 >> "%TEMP%\StartupLog.txt" 2>&1
)

これが私のpowershellスクリプト--fixpermission.ps1です。

Add-PSSnapin Microsoft.WindowsAzure.ServiceRuntime

while (!$?)
{
    echo "Failed, retrying after five seconds..."
    sleep 5

    Add-PSSnapin Microsoft.WindowsAzure.ServiceRuntime
}

echo "Added WA snapin."

$localresource = Get-LocalResource "Resources"
$folder = $localresource.RootPath

$acl = Get-Acl $folder

$rule1 = New-Object System.Security.AccessControl.FileSystemAccessRule(
  "Administrators", "FullControl", "ContainerInherit, ObjectInherit", 
  "None", "Allow")
$rule2 = New-Object System.Security.AccessControl.FileSystemAccessRule(
  "Everyone", "FullControl", "ContainerInherit, ObjectInherit", 
  "None", "Allow")

$acl.AddAccessRule($rule1)
$acl.AddAccessRule($rule2)

Set-Acl $folder $acl

echo "Done changing ACLs."

私の .cmd ファイルと fixpermission.ps1 ファイルは両方とも Web プロジェクト ディレクトリにあり、プロパティのコピーを常に = true に設定します。

ローカル マシンで startup.cmd を手動で実行すると、次のエラーが発生します。

.\fixfolderaccess.ps1 : The term '.\fixfolderaccess.ps1' is not recognized as t
he name of a cmdlet, function, script file, or operable program. Check the spel
ling of the name, or if a path was included, verify that the path is correct an
d try again.
At line:1 char:22
+ .\fixfolderaccess.ps1 <<<< 
    + CategoryInfo          : ObjectNotFound: (.\fixfolderaccess.ps1:String) [ 
   ], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Webrole にリモートでアクセスすると、下に貼り付けられたエラー メッセージが表示されます。

C a n n o t   s t a r t   W i n d o w s   P o w e r S h e l l   v e r s i o n   2 . 0   b e c a u s e   i t   i s   n o t   c o r r e c t l y   i n s t a l l e d . 

 Add-PSSnapin : Cannot load Windows PowerShell snap-in Microsoft.WindowsAzure.Se
rviceRuntime because of the following error: The Windows PowerShell snap-in mod
ule F:\plugins\RemoteAccess\Microsoft.WindowsAzure.ServiceRuntime.Commands.dll 
does not have required Windows PowerShell snap-in strong name Microsoft.Windows
Azure.ServiceRuntime.Commands, Version=1.0.0.0, Culture=neutral, PublicKeyToken
=31bf3856ad364e35.
At F:\approot\bin\fixfolderaccess.ps1:1 char:13
+ Add-PSSnapin  <<<< Microsoft.WindowsAzure.ServiceRuntime
Failed, retrying after five seconds...
out-lineoutput : The OS handle's position is not what FileStream expected. Do n
ot use a handle simultaneously in one FileStream and in Win32 code or another F
ileStream. This may cause data loss.

実際にAzure Webroleにログインし、powershellスクリプトを手動で実行したところ、以下のエラーが発生しました

Add-PSSnapin : 次のエラーのため、Windows PowerShell スナップイン Microsoft.WindowsAzure.ServiceRuntime を読み込めません: Windows PowerShell スナップイン モジュール E:\plugins\RemoteAccess\Microsoft.WindowsAzure.ServiceRuntime.Commands.dll oes が必要ありませんWindows PowerShell スナップインの厳密な名前 Microsoft.WindowsAzure.ServiceRuntime.Commands、Version=1 0.0.0、Culture=neutral、PublicKeyToken=31bf3856ad364e35。E:\sitesroot\0\bin\fixfolderaccess.ps1:8 char:17 + Add-PSSnapin <<<< Microsoft.WindowsAzure.ServiceRuntime

質問

最近、windows azure ツール バージョン 2.1 と VisualStudio2012 にアップグレードしました。しかし、プロジェクト ファイルのターゲットはまだ Framework 4.0 を指しています。すべてのプロジェクト ファイルのターゲット フレームワークを .Net4.5 にアップグレードし、すべての dll を .net 4.5 にアップグレードすると思いますか?これらの問題はすべてなくなるかもしれませんか?

Azure ローカル ストレージへの必要な書き込みアクセスを許可する簡単な方法はありますか?

4

0 に答える 0