简体   繁体   English

使用PowerShell将文件从Azure上传和下载到Windows

[英]Uploading and downloading files from Azure to Windows using PowerShell

I am writing a PowerShell script to communicate with my Microsoft Azure account, and I am facing an issue with uploading and downloading files using the Set-AzureStorageBlobContent and Get-AzureStorageBlobContent modules. 我正在编写PowerShell脚本以与我的Microsoft Azure帐户进行通信,并且使用Set-AzureStorageBlobContent和Get-AzureStorageBlobContent模块上载和下载文件时遇到了问题。

$Upload = @{
    Context = $storageContext;
    Container = $container;
    File = "C:\... \file.csv";
    }
Set-AzureStorageBlobContent @Upload -Force;

The first time I run this, it appears to start uploading, but it stays at 0% and never rises. 我第一次运行此程序,它似乎开始上传,但它始终保持在0%且从未升高。 If I cancel it and try executing my script again, I get an error that says: "Set-AzureStorageBlobContent : A transfer operation with the same source and destination already exists." 如果取消它并再次尝试执行脚本,则会收到一条错误消息:“ Set-AzureStorageBlobContent:具有相同源和目标的传输操作已存在。” A nearly identical thing happens when I try to download an existing blob from Azure. 当我尝试从Azure下载现有的Blob时,发生了几乎相同的事情。

$params = @{
    Context = $storageContext;
    Container = $container;
    Blob = $blob;
    Destination = $dest
    }
New-Item -Path $dest -ItemType Directory -Force
Get-AzureStorageBlobContent @params

I have tried reinstalling Azure.Storage, which is the module that contains the cmdlet Get-AzureStorageBlobContent and Set-AzureStorageBlobContent, but I had no luck. 我尝试重新安装Azure.Storage,它是包含cmdlet Get-AzureStorageBlobContent和Set-AzureStorageBlobContent的模块,但是我没有运气。 Am I doing something incorrectly, or is this code just wrong somehow? 我做错了什么,还是这段代码是错误的?

It seems to be something with your $Upload variable. $ Upload变量似乎与某物有关。 Try this instead: 尝试以下方法:

Get-ChildItem –Path C:\Images\* | Set-AzureStorageBlobContent -Container "yourcontainername"

more info: https://docs.microsoft.com/en-us/azure/storage/storage-powershell-guide-full 更多信息: https : //docs.microsoft.com/zh-cn/azure/storage/storage-powershell-guide-full

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 windows 7 上使用 powershell 2.0 下载文件 - 来自 Microsoft - Downloading files with powershell 2.0 on windows 7 - From Microsoft 使用 Powershell 从 Internet 下载文件并取得进展 - Downloading files from the Internet using Powershell with progress 使用Powershell脚本上传到Windows Azure时出错 - Error While uploading to windows Azure using powershell Script Powershell如何在与存储之间上传/下载数据时调用Azure API - How powershell calls the azure API while uploading/downloading data to & from storage 使用 Azure Runbook Powershell 从 SFTP 服务器下载文件 - downloading file from a SFTP server using Azure Runbook Powershell 使用Powershell下载文本文件 - Downloading Text Files Using Powershell 在 Windows 命令提示符/PowerShell 中下载大文件 - Downloading large files in Windows command prompt / PowerShell 使用 PowerShell 从 FTP 站点下载多个文件 - Downloading multiple files from FTP site using PowerShell PowerShell 从具有最新日期的列表中下载文件 - PowerShell Downloading Files from a List with the latest Date 从 Windows Powershell 脚本上传到 Artifactory - Uploading to Artifactory from a Windows Powershell script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM