Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/01f859ca0e409e9c5cea49f3fdeca059 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/01f859ca0e409e9c5cea49f3fdeca059 to your computer and use it in GitHub Desktop.
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