ili*_*rve 3 powershell azure azure-functions
所以我正在尝试开发一个函数,该函数将从Azure存储队列中读取数据并将其写入Azure存储表.我似乎找不到任何相关的东西.我找到了读取队列的代码:
$in = Get-Content $triggerInput
Write-Output "PowerShell script processed queue message '$in'"
Run Code Online (Sandbox Code Playgroud)
但是没有例子写到表中,所以我不知道该怎么做.
最近我做了同样的功能,你可以在这里找到这些例子.你需要这个功能QueueTrigger-PowerShell.心连心
$json = Get-Content $triggerInput | ConvertFrom-Json
Write-Output "PowerShell script processed queue message '$json'"
$title = "PowerShell Table Entity for message {0}" -f $json.id
$entity = [PSObject]@{
Status = 0
Title = $title
}
$entity | ConvertTo-Json | Out-File -Encoding UTF8 $outputTable
Run Code Online (Sandbox Code Playgroud)
要控制写入数据的表,可以使用function.json.对我来说,那里指定了行和分区键:
{
"type": "table",
"name": "outputTable",
"tableName": "pancakeTable",
"connection": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"direction": "out",
"partitionKey": "some value",
"rowKey": "I don't remember what was here but it was some form of variable (guid) generated from the request by Azure"
}
Run Code Online (Sandbox Code Playgroud)
这是我的function.json,但最初它将分区和行键值硬编码到其中.现在我正在使用powershell来生成那些(从此线程中的另一个答案复制粘贴):
PartitionKey = $requestBody.room
RowKey = get-date -Format "yyyy-MM-dd H:m:s.ms"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1391 次 |
| 最近记录: |