【问题标题】:Download multiple powershell files from Azure Storage container as a Zip从 Azure 存储容器以 Zip 格式下载多个 powershell 文件
【发布时间】:2019-02-08 11:01:46
【问题描述】:
如何从 Azure 存储下载所有 PowerShell 文件
通过 power shell cmdlet 将帐户容器保存到 zip 文件夹?
截至目前,以下 cmdlet 有助于按名称下载特定 blob
$blob = Get-AzureStorageBlobContent -Container hemac -Blob "CreateAndDeploy-Eventhubs.ps1" -Context $ctx -Destination $f -Force
【问题讨论】:
标签:
azure
powershell
azure-blob-storage
zipfile
azure-web-app-service
【解决方案1】:
首先设置一个文件夹来下载所有的blob
1.提供您希望用于下载 blob 的目录的完整路径
$DestinationFolder = "<C:\DownloadedBlobs>"
创建目标目录并下载 blob
New-Item -Path $DestinationFolder -ItemType Directory -Force
$blob | Get-AzureStorageBlobContent –Destination $DestinationFolder
现在压缩整个文件夹。
$folderToZip = "C:\DownloadedBlobs"
$rootfolder = Split-Path -Path $folderToZip
$zipFile = Join-Path -Path $rootfolder -ChildPath "ZippedFile.zip"
那么你应该使用这个 - docs
Compress-Archive -Path $folderToZip -DestinationPath $zipFile -Verbose
压缩后的文件将与下载文件夹位于同一目录中