gpt4 book ai didi

powershell - 使用 powershell -> LoaderException 从 Azure 存储下载 blob

转载 作者:行者123 更新时间:2023-12-03 00:02:05 31 4
gpt4 key购买 nike

我在 Azure 启动任务中使用 powershell 从 blobstorage 下载 blob。我今天通过 NuGet 将 Microsoft.WindowsAzure.Storage 库从 3.0.3.0 更新到 4.0.1.0。

在库更新文件仍然正确下载后,但我在命令窗口中收到相同类型的警告:

'无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。'

function download_from_storage ($container, $blob, $connection, $destination) {
Add-Type -Path ((Get-Location).Path + '\Microsoft.WindowsAzure.Storage.dll')
$storageAccount = [Microsoft.WindowsAzure.Storage.CloudStorageAccount]::Parse($connection)
$blobClient = New-Object Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient($storageAccount.BlobEndpoint, $storageAccount.Credentials)
$container = $blobClient.GetContainerReference($container)
$remoteBlob = $container.GetBlockBlobReference($blob)
$remoteBlob.DownloadToFile($destination + "\" + $blob, [System.IO.FileMode]::OpenOrCreate)
}

$connection_string = 'DefaultEndpointsProtocol=https;AccountName=<AcountName>;AccountKey=<Accountkey>'

# JRE
$jre = 'jre-7u60-windows-x64.exe'
$node = 'node-v0.10.29-x64.msi'
download_from_storage 'java-runtime' $jre $connection_string (Get-Location).Path
download_from_storage 'nodejs' $node $connection_string (Get-Location).Path

由于它仍在工作,我只是不知道为什么该消息首先出现。

最佳答案

这并不完全是您问题的答案,但这是从 Blob 存储下载文件的更简单的方法:

$dlPath = "C:\temp\"
$container = "BlobContainer"
Set-AzureSubscription "NameOfYourSubscription" -CurrentStorageAccount "storageAccountName"
Get-AzureStorageContainer $container | Get-AzureStorageBlob |
Get-AzureStorageBlobContent -Destination $container

关于powershell - 使用 powershell -> LoaderException 从 Azure 存储下载 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24301949/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com