2016-04-15 50 views
0

我有一个Azure云服务工作者角色,需要安装单独的Windows服务才能将应用程序跟踪重定向到中央服务器。我已将此Windows服务的安装二进制文件放入存储帐户的文件存储中,如下所示。然后,我的启动任务调用一个批处理文件,该文件又执行一个Power-Shell脚本来检索文件并安装服务问题使用启动脚本访问Azure WorkerRole中的文件存储

当Azure部署角色的新实例时,脚本执行失败,并显示以下错误:

Cannot find path '\\{name}.file.core.windows.net\utilities\slab1-1.zip' because it does not exist

但是,当我通过RDP连接后运行脚本时,一切正常。有人知道为什么会发生这种情况吗?这里是下面的脚本...

cmdkey /add:$storageAccountName.file.core.windows.net /user:$shareUser /pass:$shareAccessKey 

net use * \\$storageAccountName.file.core.windows.net\utilities 

mkdir slab 
copy \\$storageAccountName.file.core.windows.net\utilities\$package .\slab\$package 

回答

1

我一直有问题,在这里和那里通过使用脚本来访问安装的蔚蓝文件驱动器。我相信这或多或少与驱动器相关,仅针对当前用户安装,并且从脚本调用时可能并不总是相同。

我最终没有网络驱动器从硬盘的方式拉取来自azure文件的文件。这里

$source= $stroageAccountName 
$sourceKey = $shareAccessKey 
$sharename = "utilities" 
$package = "slab1-1.zip" 
$dest = ".\slab\" + $package 

#Define Azure file share root 
$ctx=New-AzureStorageContext $source $sourceKey 
$share = get-AzureStorageShare $sharename -Context $ctx 
Get-AzureStorageFileContent -share $share -Destination $dest -Path $package -confirm:$false 

代码示例将让你一个良好的开端: https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-files/

这将是很难,如果你有更复杂的文件夹结构来管理,但对象有CloudFileDirectoryCloudFile,财产和方法有工作无缝地为我的PowerShell 4.0

* Azure Powershell模块需要 'GET-AzureStorageFileContent' cmdlet的

+0

这是真棒,谢谢对于所有正确参数的相关示例! – ohlando

相关问题