I have an Azure Table called csvtable that has about a million rows. I want to query this using an Azure Function and return one row.
What I have tried is using an input integration with the table, but AFAIK, this only gives me subset of data inside a $inputTable variable to filter on.
I've also tried turning on the identity and using Get-AzStorageTable cmdlets, but this results in a HTTP 500, I assume it has to do with that Managed Identities do not support Table Storage (yet?) link
The code runs fine locally:
$storageAccountName = 'storageAccountName '
$storageAccountkey = 'storageAccountkey'
$tableName = "MyTable"
$storageContext = (New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountkey).Context
$table = (Get-AzStorageTable -Table $tableName -Context $storageContext).CloudTable
Get-AzTableRow -Table $table -CustomFilter "(PartitionKey eq '0401' and EnterpriseNumber eq '0401.021.061')"
I ended up using the REST API route as suggested by one of the top comments.
Using Managed Identity I couldn't even retrieve the Azure Table.
Using the StorageAccount and SAS-key combo, I could retrieve the Table, but when trying to fetch data using Get-AzTableRow it seems that the cmdlet was not installed in the Function.
UPDATE
I managed to get it working by adding the AzTable Module
To achieve this in the portal:
Click on the root of your function app
In the Function App settings, go to Development Tools
Open the Advanced Tools (Kudu)
Select Debug Console, PowerShell (top bar)
cd to home\site\wwwroot
add a AzTable = '2.*' keypair to the .\requirements.psd1 (using Set-Content)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With