Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Output Azure Function Data to Azure Table Service with an PowerShell Azure Function. Associated blog https://blog.darrenjrobinson.com/leveraging-the-azure-functions-table-storage-output-binding-with-powershell/
$breweryDBURI = 'https://sandbox-api.brewerydb.com/v2/'
$key = 'myAPIKey'
$stylesURI = "$($breweryDBURI)styles?key=$($key)"
$beerStyles = Invoke-RestMethod -Uri $stylesURI -Method Get
[PSObject []] $outputArray = $null
foreach ($style in $beerStyles.data){
$entity = [PSObject]@{
partitionKey = 'myEvents'
rowKey = $style.name.Replace("/","-")
name = $style.shortName
ibuMin = $style.ibuMin
ibuMax = $style.ibuMax
abvMax = $style.abvMax
abvMin = $style.abvMin
srmMax = $style.srmMax
srmMin = $style.srmMin
ogMax = $style.ogMax
ogMin = $style.ogMin
fgMax = $style.fgMax
fgMin = $style.fgMin
}
$outputArray += $entity
}
if ($outputArray){
write-host "$($outputArray.Count) Styles"
# write rows out to the Table
$outputArray | ConvertTo-Json | Out-File $outputTable
$outputTable.done
}
Out-File -Encoding Ascii -FilePath $res -inputObject "$($outputArray.Count) Styles added to Azure Table Service"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.