Home > other >  Azure Functions PowerShell - Accessing Timestamp value from Azure Storage Table
Azure Functions PowerShell - Accessing Timestamp value from Azure Storage Table

Time:06-18

I am building a timer-triggered Azure Function that uses a PowerShell script. For input binding, there is Azure Table Storage. In order to use newly added values in my script, I was hoping to make use of the automatic Timestamp value that gets generated on each value addition to the table. However, the Timestamp is rendered empty when I run the function. The values are present in the table though.

My test code -

# Input bindings are passed in via param block.
param($Timer, $inputTable)

$newValues = $inputTable.GetEnumerator()
$newValues | ForEach-Object {
    Write-host $_.Timestamp
}

Output when Write-host $_.Timestamp

2022-06-17T07:16:55.538 [Information] OUTPUT:
2022-06-17T07:16:55.614 [Information] INFORMATION:
2022-06-17T07:16:55.616 [Information] INFORMATION:
2022-06-17T07:16:55.621 [Information] INFORMATION:

Output for any other value Eg. Write-host $_.PartitionKey -

2022-06-17T07:17:34.230 [Information] OUTPUT:
2022-06-17T07:17:34.310 [Information] INFORMATION: partition1
2022-06-17T07:17:34.312 [Information] INFORMATION: partition1
2022-06-17T07:17:34.318 [Information] INFORMATION: partition1

CodePudding user response:

If you are using the enter image description here

function.json

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "Request",
      "methods": [
        "get"
      ],
      "route": "get/user"
    },
    {
      "name": "PersonEntity",
      "type": "table",
      "tableName": "users",
      "connection": "MyStorageConnectionAppSetting",
      "direction": "in"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "Response"
    }
  ]
}

run.ps1

When I trigger the function it returns all users but the TimeStamp property is not returned from table storage. I don't think there's a way to retrieve this using the input binding.

Debugging Output

enter image description here

Also looks like someone logged an issue here:

https://github.com/Azure/azure-functions-nodejs-worker/issues/320

And this is the same as with Python and NodeJs bindings so not unique to PowerShell.

You could use the AzTable module that was linked in the other answer or there is another module (AzBobbyTables) in the PowerShell Gallery which is newer and written in C# and is supposed to be much more performant:

https://www.powershellgallery.com/packages/AzBobbyTables/2.0.0

https://twitter.com/PalmEmanuel/status/1462818044959461382

  • Related