我想創建一個Azure函數,執行PowerShell與存儲隊列觸發器。出於測試目的,我希望此功能可以處理OneDrive for Business帳戶中的文件。要將文件複製到aapdftoimage/ThreePages.pdf
到aapdftoimage/output_ThreePages.pdf
。Azure函數與PowerShell,存儲隊列觸發器和OneDrive業務
當OneDrive for Business作爲輸入集成時,任何時候該函數由隊列中的新消息觸發時都會收到錯誤。如果我斷開OneDrive作爲輸入,我不會收到任何錯誤,並且包含該消息。
的錯誤是:
2017-05-25T22:24:38.484 Function started (Id=a0c37fdf-ed3c-473c-9c79-236d63531e7e)
2017-05-25T22:24:38.499 Function completed (Failure, Id=a0c37fdf-ed3c-473c-9c79-236d63531e7e, Duration=1ms)
2017-05-25T22:24:38.562 Exception while executing function: Functions.QueueTriggerPowerShell1. Microsoft.Azure.WebJobs.Host: No value for named parameter 'file'.
這裏是我的PowerShell:
$inData = Get-Content $triggerInput
$inFile = Get-Content $inputFile
Write-Output "PowerShell script processed queue message '$inData'"
Write-Output "inFile: $inFile"
這裏的function.json:
{
"bindings": [
{
"name": "triggerInput",
"type": "queueTrigger",
"direction": "in",
"queueName": "samples-powershell-pdftoimage",
"connection": "<storageaccount>_STORAGE"
},
{
"type": "apiHubFile",
"name": "inputFile",
"path": "aapdftoimage/{file}",
"connection": "onedriveforbusiness1_ONEDRIVEFORBUSINESS",
"direction": "in"
}
],
"disabled": false
}
正如我寫這篇文章,我想我的一部分混淆在OneDrive for Business的輸入和輸出(未連接在我的測試中)。
我知道$triggerInput
是什麼。這是消息的內容。但$inputFile
是什麼? {file}
從哪裏來?
我想,也許我會做以下,但它也不能正常工作(同樣的錯誤):
$file = Get-Content $triggerInput
我想這可能定義爲$inputFile
「aapdftoimage/$文件」,但它什麼都不做的分類。
不用說,我處於停滯狀態。任何人都可以給我一些指導,並理順我嗎?
謝謝!它正在工作!我認爲這是很多魔術。很多事情都是自動發生的。我寧願明確地獲取內容,從JSON轉換,分配給{file},然後知道inputFile和outputFile是什麼。 – Chris76786777
是的,你的觀察是正確的。無法在代碼中分配{file}是現階段已知的限制。這適用於處於試驗階段的Azure函數支持的所有語言。我們計劃在未來的版本中解決這個問題,但目前沒有ETA。 –
太好了。聽到那個消息很開心。 – Chris76786777