当我尝试将文件从 azure blob 下载到 azure localstorage 时,它向我显示一条消息“拒绝访问路径 'C:\Resources\directory....'。作为一种解决方法,我添加了一个具有电源的状态任务shell命令启用权限。但在此之后,我的网络角色被发现需要更多时间来启动并最终启动。但是当我尝试写入它时,我仍然收到拒绝访问错误消息.
感谢您解决此问题的建议
我还尝试将我的 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 项目目录中,并设置属性 copy always=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 Windows PowerShell 管理单元强名称 Microsoft.WindowsAzure.ServiceRuntime.Commands,版本=1 0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35。在 E:\sitesroot\0\bin\fixfolderaccess.ps1:8 char:17 + Add-PSSnapin <<<< Microsoft.WindowsAzure.ServiceRuntime
问题
我最近升级到 windows azure tools ver 2.1 和 VisualStudio2012。但是我的项目文件目标仍然指向 Framework 4.0。你认为如果我将所有项目文件的目标框架升级到 .Net4.5 并将每个 dll 升级到 .net 4.5 和所有这些烦恼可能会消失吗?
Is there a straight forward way to grant required write access to azure local storage?