【发布时间】:2023-03-04 11:30:01
【问题描述】:
我一直在运行一个脚本,将我的所有 BLOB 文件下载到我的 Windows 机器上。我没有问题。现在我正在尝试在我的 Ubuntu 16.10 上做同样的事情。
我已经在我的发行版上安装了 PowerShell。当我尝试运行我的脚本时:
Clear-Host
$SubscriptionName = "MySubName"
$StorageAccountName = "MyStorageAccountName"
$StorageAccountKey = "SecretKey"
$ContainerName = "MyContainerName"
$localTargetDirectory = "/home/"
#Set up the storage account context
$ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
Get-AzureStorageContainer -Context $ctx
$blobs = Get-AzureStorageBlob -Container $ContainerName -Context $ctx
foreach($Blob in $blobs){
Get-AzureStorageBlobContent -Blob $Blob.Name -Container $ContainerName -Destination $localTargetDirectory -Context $ctx -Force
}
PowerShell 无法识别多个命令。
New-AzureStorageContext : The term 'New-AzureStorageContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At /home/file.ps1
所以我尝试安装 AzureRM 模块:
PS /home> Install-Module AzureRM
它有效。现在我导入模块:
PS /home> Import-Module AzureRM
Import-Module : The specified module 'AzureRM' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ import-module <<<< azurerm
+ CategoryInfo : ResourceUnavailable: (azurerm:String) [Import- Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
如何解决这个问题?可以直接下载模块文件放到模块目录下吗?
编辑:
我尝试像这样手动下载AzureRM模块(4.3.1版):
PS /home> Save-Module -Name AzureRM -Path ~/.local/share/powershell/modules/ -RequiredVersion 4.3.1
PS /home> Install-Module -Name AzureRM
模块确实下载了,安装没有输出,仍然无法工作。
编辑:
我发现了另一个不使用 PowerShell 的工具。 AzCopy
【问题讨论】:
-
您好,您的存储帐户是经典模式存储帐户吗?现在,Linux 不支持经典的 Azure PowerShell cmdlet。
-
我没有找到经典的符号。我猜这是一个新的存储帐户。
标签: linux powershell azure azure-blob-storage