3

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')"
1
  • 1
    Please edit your question and include any code that you have written. Commented Mar 26, 2020 at 9:27

1 Answer 1

2

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)

Sign up to request clarification or add additional context in comments.

2 Comments

Do you have the AzTable module installed into your Function app, using requirements.psd1 or any other means?
No, but when I did add it it worked, I updated it how to do it for future reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.