[英]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.