使用启动脚本访问 Azure WorkerRole 中的文件存储
Issue Accessing File Storage in Azure WorkerRole using Startup Script
我有一个 Azure 云服务工作者角色,它需要安装一个单独的 Windows 服务以将应用程序跟踪重定向到中央服务器。我已将此 Windows 服务的安装二进制文件放在存储帐户的文件存储中,如下所示。然后我让我的启动任务调用一个批处理文件,它依次执行 power-shell 脚本来检索文件并安装服务
当 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
我在使用脚本访问安装的 Azure 文件驱动器时总是遇到问题。我相信这或多或少与驱动器只为当前用户安装有关,并且在从脚本调用时可能并不总是相同。
我最终在没有网络驱动器的情况下艰难地从 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/
如果你有更复杂的文件夹结构,管理起来会更困难,但是那里的对象 CloudFileDirectory and CloudFile、属性 和方法在 powershell 4.0
中对我来说是无缝的
*Azure Powershell 'Get-AzureStorageFileContent' cmdlet
需要模块
我有一个 Azure 云服务工作者角色,它需要安装一个单独的 Windows 服务以将应用程序跟踪重定向到中央服务器。我已将此 Windows 服务的安装二进制文件放在存储帐户的文件存储中,如下所示。然后我让我的启动任务调用一个批处理文件,它依次执行 power-shell 脚本来检索文件并安装服务
当 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
我在使用脚本访问安装的 Azure 文件驱动器时总是遇到问题。我相信这或多或少与驱动器只为当前用户安装有关,并且在从脚本调用时可能并不总是相同。
我最终在没有网络驱动器的情况下艰难地从 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/
如果你有更复杂的文件夹结构,管理起来会更困难,但是那里的对象 CloudFileDirectory and CloudFile、属性 和方法在 powershell 4.0
中对我来说是无缝的*Azure Powershell 'Get-AzureStorageFileContent' cmdlet
需要模块