[英]Azure WebJob with Powershell Script to upload file to Azure Blob storage
I am trying to run powershell script as Azure Web Job (simple one that comes with WebApps) that is responsible for creating PDF file and uploading that file to Azure Blob Storage. 我正在尝试将Powershell脚本作为Azure Web Job(WebApp附带的简单脚本)运行,该脚本负责创建PDF文件并将该文件上传到Azure Blob存储。 When file is successfully created there is an error during file upload using following commands:
成功创建文件后,使用以下命令在文件上传期间会出现错误:
$pdfFileName = $reportId + ".pdf";
$storageAccountName = "MY-STORE"
$storageAccountKey = "MY-KEY"
$containerName = "_MY_CONTAINER"
$fullFileName = $PSScriptRoot + "\" + $pdfFileName
$ctx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
Set-AzureStorageBlobContent -File "$fullFileName" -Container $containerName -Blob $pdfFileName -Context $ctx -Force
As a result I have following message that is displayed in Azure Web Jobs logs (in Kudu portal). 结果,我在Azure Web作业日志(在Kudu门户中)中显示了以下消息。
[11/15/2016 15:20:24 > 89499f: ERR ] Set-AzureStorageBlobContent : Win32 internal error "The handle is invalid" 0x6
[11/15/2016 15:20:24 > 89499f: ERR ] occurred while reading the console output buffer. Contact Microsoft Customer
[11/15/2016 15:20:24 > 89499f: ERR ] Support Services.
[11/15/2016 15:20:24 > 89499f: ERR ] At
[11/15/2016 15:20:24 > 89499f: ERR ] D:\local\Temp\jobs\triggered\ddd\orgmoz1g.dqi\generateAndUploadReports.ps1:53
[11/15/2016 15:20:24 > 89499f: ERR ] char:3
[11/15/2016 15:20:24 > 89499f: ERR ] + Set-AzureStorageBlobContent -File $fullFileName -Container
[11/15/2016 15:20:24 > 89499f: ERR ] $containerName -Blo ...
[11/15/2016 15:20:24 > 89499f: ERR ] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[11/15/2016 15:20:24 > 89499f: ERR ] ~~~~~~
[11/15/2016 15:20:24 > 89499f: ERR ] + CategoryInfo : ReadError: (:) [Set-AzureStorageBlobContent], Ho
[11/15/2016 15:20:24 > 89499f: ERR ] stException
[11/15/2016 15:20:24 > 89499f: ERR ] + FullyQualifiedErrorId : ReadConsoleOutput,Microsoft.WindowsAzure.Command
[11/15/2016 15:20:24 > 89499f: ERR ] s.Storage.Blob.SetAzureBlobContentCommand
Same script works correctly on my local machine. 同一脚本在我的本地计算机上可以正常工作。 What is more when I created webjob just to list available modules using Get-Module -ListAvailable i received modules with following ones as well.
当我创建webjob只是为了使用Get-Module -ListAvailable列出可用模块时, 还收到了以下模块。
...
[11/15/2016 15:40:36 > 89499f: INFO] ModuleType Version Name ExportedCommands
[11/15/2016 15:40:36 > 89499f: INFO] ---------- ------- ---- ----------------
[11/15/2016 15:40:36 > 89499f: INFO] Manifest 1.4.0 Azure {Get-AzureAutomati...
...
[11/15/2016 15:40:36 > 89499f: INFO] ModuleType Version Name ExportedCommands
[11/15/2016 15:40:36 > 89499f: INFO] ---------- ------- ---- ----------------
[11/15/2016 15:40:36 > 89499f: INFO] Manifest 1.1.2 Azure.Storage {Get-AzureStorageB...
...
According to your description, I could reproduce your issue. 根据您的描述,我可以重现您的问题。 After some trials, I assumed that it was due to PowerShell Progress Indicators which provides progress indicators in the UI during long-running operations.
经过一些试验后,我认为这是由于PowerShell进度指示器在长时间运行的操作中在UI中提供了进度指示器。 You could try to disable progress indicators in Power Shell by executing the following command before you call
Set-AzureStorageBlobContent
: 您可以在调用
Set-AzureStorageBlobContent
之前通过执行以下命令来尝试禁用Power Shell中的进度指示器:
$ProgressPreference="SilentlyContinue"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.