Last active
April 16, 2019 21:09
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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