在计时器模式下使用 Azure Functions 填充存储 Table
Using Azure Function in timer mode to populate a Storage Table
我正在尝试使用 node.js 中带有计时器计划的函数将数据发送到 Azure 存储 Table。
module.exports = function (context, myTimer, outputTable) {
var timeStamp = new Date().toISOString();
context.log('JavaScript timer trigger function ran!', timeStamp);
context.bindings.outputTable = [];
for (var i = 1; i < 10; i++) {
context.bindings.outputTable.push({
PartitionKey: "Test",
RowKey: i.toString(),
Name: "Name " + i
});
}
};
function.js:
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 5 * * * *"
},
{
"type": "table",
"name": "outputTable",
"tableName": "contmaticfunc",
"connection": "contmatic9acd_STORAGE",
"direction": "out"
}
]
}
代码运行没有任何错误,但我看不到table上的数据。
我不确定参数函数 outputTable。我错过了什么吗?
此致
根据我的测试,我们可以使用以下步骤将数据发送到Azure Storage Table。
- 添加 Azure Table 存储作为输出绑定
2.代码
module.exports = async function (context, myTimer,outputTable) {
var timeStamp = new Date().toISOString();
if (myTimer.IsPastDue)
{
context.log('JavaScript is running late!');
}
context.log('JavaScript timer trigger function ran!', timeStamp);
context.bindings.outputTable = [];
for (var i = 1; i < 10; i++) {
context.bindings.outputTable.push({
PartitionKey: "MyTest"+ i,
RowKey: i.toString(),
Name: "Name " + i
});
}
context.done();
};
- 勾选
我用PowerShell来检查
Install-Module AzTable
$groupName=""
$accountName=""
$tableName=""
Connect-AzAccount
$table = Get-AzTableTable -resourceGroup $groupName -storageAccountName $accountName -TableName $tableName
Get-AzTableRow -Table $table
我正在尝试使用 node.js 中带有计时器计划的函数将数据发送到 Azure 存储 Table。
module.exports = function (context, myTimer, outputTable) {
var timeStamp = new Date().toISOString();
context.log('JavaScript timer trigger function ran!', timeStamp);
context.bindings.outputTable = [];
for (var i = 1; i < 10; i++) {
context.bindings.outputTable.push({
PartitionKey: "Test",
RowKey: i.toString(),
Name: "Name " + i
});
}
};
function.js:
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 5 * * * *"
},
{
"type": "table",
"name": "outputTable",
"tableName": "contmaticfunc",
"connection": "contmatic9acd_STORAGE",
"direction": "out"
}
]
}
代码运行没有任何错误,但我看不到table上的数据。 我不确定参数函数 outputTable。我错过了什么吗?
此致
根据我的测试,我们可以使用以下步骤将数据发送到Azure Storage Table。
- 添加 Azure Table 存储作为输出绑定
module.exports = async function (context, myTimer,outputTable) {
var timeStamp = new Date().toISOString();
if (myTimer.IsPastDue)
{
context.log('JavaScript is running late!');
}
context.log('JavaScript timer trigger function ran!', timeStamp);
context.bindings.outputTable = [];
for (var i = 1; i < 10; i++) {
context.bindings.outputTable.push({
PartitionKey: "MyTest"+ i,
RowKey: i.toString(),
Name: "Name " + i
});
}
context.done();
};
- 勾选
我用PowerShell来检查
Install-Module AzTable
$groupName=""
$accountName=""
$tableName=""
Connect-AzAccount
$table = Get-AzTableTable -resourceGroup $groupName -storageAccountName $accountName -TableName $tableName
Get-AzTableRow -Table $table