使用启动脚本访问Azure WorkerRole中的文件存储时出现问题 [英] Issue Accessing File Storage in Azure WorkerRole using Startup Script

查看:57
本文介绍了使用启动脚本访问Azure WorkerRole中的文件存储时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure Cloud Service Worker角色,该角色需要安装单独的Windows Service才能将应用程序跟踪重定向到集中式服务器.我已将此Windows服务的安装二进制文件放在存储帐户的文件存储中,如下所示.然后,我将启动任务称为批处理文件,该文件又执行一个Power-shell脚本来检索该文件并安装服务

I have an Azure Cloud Service Worker Role which needs a separate Windows Service installed to redirect application tracing to a centralized server. I've placed the installation binaries for this Windows Service in a Storage Account's file storage as shown below. I then have my startup task call a batch file, which in turn executes a power-shell script to retrieve the file and install the service

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

When Azure deploys a new instance of the role, the script execution fails with the following error:

找不到路径'\\ {name} .file.core.windows.net \ utilities \ slab1-1.zip',因为它确实不存在

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

但是,当我通过RDP连接后运行脚本时,一切都很好.有人知道为什么会这样吗?这是下面的脚本...

However, when I run the script after connecting through RDP, all is fine. Does anybody know why this might be happening? Here is the script below...

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

推荐答案

我总是在这里和那里遇到问题,方法是使用脚本访问已安装的Azure文件驱动器.我相信这或多或少与只为当前用户安装驱动器有关,并且从脚本调用时可能并不总是相同.

I always have problem here and there by using a script to access the mounted azure file drive. I believe this is more or less related to the drive is mounted only for the current user and may not always work the same when called from a script.

我最终在没有网络驱动器的情况下以困难的方式从azure文件中拉出文件.

I ended up pulling files from azure file the hard way without network drive.

$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/

Code example here will get you a good start: https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-files/

如果文件夹结构更复杂,则很难管理,但是其中的对象是 CloudFile ,在那里的属性和方法在Powershell 4.0中对我来说都是无缝的

It would be harder to manage if you have more complex folder structure, but objects there are CloudFileDirectory and CloudFile, property and methods there works seamlessly for me in powershell 4.0

* Azure Powershell 模块是必需的'Get-AzureStorageFileContent'cmdlet

*Azure Powershell module is required for 'Get-AzureStorageFileContent' cmdlet

这篇关于使用启动脚本访问Azure WorkerRole中的文件存储时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆